Forge
csharpdeeb25a2
1using CascadeIDE.Contracts;
2
3namespace CascadeIDE.Features.HybridIndex.Application;
4
5/// <summary>Сжатие длинных путей/строк для строк HIS (как ECAM).</summary>
6[PresentationProjection("presentation-his-shorten")]
7public static class HybridIndexHisPathDisplayShortener
8{
9 public static string ShortenLikeEcam(string text)
10 {
11 if (string.IsNullOrWhiteSpace(text) || text == "—")
12 return "—";
13
14 var s = text.Trim();
15 try
16 {
17 if (s.IndexOf(Path.DirectorySeparatorChar) >= 0 || s.IndexOf(Path.AltDirectorySeparatorChar) >= 0)
18 {
19 var trimmed = s.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
20 var name = Path.GetFileName(trimmed);
21 if (!string.IsNullOrWhiteSpace(name))
22 return name;
23 }
24 }
25 catch
26 {
27 // ignore
28 }
29
30 const int max = 34;
31 if (s.Length <= max)
32 return s;
33 return s[..(max - 1)] + "…";
34 }
35}
36
View only · write via MCP/CIDE