Forge
csharpdeeb25a2
1using CascadeIDE.Contracts;
2
3namespace CascadeIDE.Features.Search.Application;
4
5/// <summary>Сборка строк из совпадений <see cref="RipgrepWorkspaceMatch"/> после поиска.</summary>
6[PresentationProjection("command palette goto ripgrep rows")]
7public static class CommandPaletteGoToRipgrepNavRowsProjection
8{
9 private const int PreviewMaxChars = 160;
10
11 public static IEnumerable<CommandPaletteGoToNavRowPresentation> FromMatches(
12 IReadOnlyList<RipgrepWorkspaceMatch> matches,
13 string workspaceRoot,
14 GoToAllQuery query)
15 {
16 var prefix = $"{query.Prefix}:";
17 foreach (var m in matches)
18 {
19 var rel = CommandPaletteGoToWorkspacePresentation.TryRelativePath(workspaceRoot, m.Path);
20 var preview = m.LineText.Trim();
21 if (preview.Length > PreviewMaxChars)
22 preview = preview[..(PreviewMaxChars - 1)] + "…";
23
24 var subtitle = rel is not null
25 ? $"{rel} · {m.LineNumber}"
26 : $"{m.Path} · {m.LineNumber}";
27
28 yield return new CommandPaletteGoToNavRowPresentation(
29 Title: preview,
30 SubtitleCategory: subtitle,
31 FullPath: m.Path,
32 Line: m.LineNumber,
33 Column: 1,
34 PrefixHint: prefix);
35 }
36 }
37}
38
View only · write via MCP/CIDE