search set line position of selected file

This commit is contained in:
Matt Parker
2025-09-25 01:01:45 +10:00
parent f8cd8d18d5
commit a5e6ece9f3
10 changed files with 49 additions and 16 deletions

View File

@@ -0,0 +1,7 @@
namespace SharpIDE.Application.Features.Analysis;
public struct SharpIdeFileLinePosition
{
public required int Line { get; set; }
public required int Column { get; set; }
}

View File

@@ -31,6 +31,7 @@ public static class AsyncEventExtensions
{
public static void InvokeParallelFireAndForget(this MulticastDelegate @event) => FireAndForget(() => @event.InvokeParallelAsync());
public static void InvokeParallelFireAndForget<T>(this MulticastDelegate @event, T arg) => FireAndForget(() => @event.InvokeParallelAsync(arg));
public static void InvokeParallelFireAndForget<T, U>(this MulticastDelegate @event, T arg, U arg2) => FireAndForget(() => @event.InvokeParallelAsync(arg, arg2));
private static async void FireAndForget(Func<Task> action)
{
@@ -53,6 +54,10 @@ public static class AsyncEventExtensions
{
return InvokeDelegatesAsync(@event.GetInvocationList(), del => ((Func<T, Task>)del)(arg));
}
public static Task InvokeParallelAsync<T, U>(this MulticastDelegate @event, T arg, U arg2)
{
return InvokeDelegatesAsync(@event.GetInvocationList(), del => ((Func<T, U, Task>)del)(arg, arg2));
}
private static async Task InvokeDelegatesAsync(IEnumerable<Delegate> invocationList, Func<Delegate, Task> delegateExecutorDelegate)
{

View File

@@ -5,6 +5,7 @@ namespace SharpIDE.Application.Features.Search;
public class SearchResult
{
public required SharpIdeFile File { get; set; }
public required int LineNumber { get; set; }
public required int Line { get; set; }
public required int StartColumn { get; set; }
public required string LineText { get; set; }
}

View File

@@ -28,7 +28,8 @@ public static class SearchService
results.Add(new SearchResult
{
File = file,
LineNumber = index + 1,
Line = index + 1,
StartColumn = line.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) + 1,
LineText = line.Trim()
});
}