code_review: PR #1402

- it's unnecessary to implement `IEnumerable` interface
- we should check `IsIntersecting` before creating `InlineElement` to avoid unnecessary works suck as running `git cat-file -t <hash>`
- sort whold list after all elements have been added to avoid unnecessary memmove in `Insert`

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-08 11:09:20 +08:00
parent fe54d30b70
commit 84fb39f97a
No known key found for this signature in database
7 changed files with 52 additions and 88 deletions

View file

@ -48,8 +48,9 @@ namespace SourceGit.Views
var inlines = new List<Inline>();
var pos = 0;
foreach (var link in links)
for (var i = 0; i < links.Count; i++)
{
var link = links[i];
if (link.Start > pos)
inlines.Add(new Run(message.Substring(pos, link.Start - pos)));
@ -95,8 +96,7 @@ namespace SourceGit.Views
point = new Point(x, y);
var pos = TextLayout.HitTestPoint(point).TextPosition;
if (links.Lookup(pos) is { } link)
if (links.Intersect(pos, 1) is { } link)
SetHoveredIssueLink(link);
else
ClearHoveredIssueLink();