mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-16 07:55:00 +00:00
refactor: collecting inlines for subjects (#1402)
Instead of checking intersections of inline elements yourself before adding an inline element, the new class `InlineElementCollector` prevents intersections internally. Additionally the inline elements are sorted by the new class, so it's no longer necessary to do this after adding the inline elements.
This commit is contained in:
parent
ba4c0f0cd2
commit
fe54d30b70
6 changed files with 109 additions and 79 deletions
|
@ -167,19 +167,6 @@ namespace SourceGit.Views
|
|||
|
||||
var start = match.Index;
|
||||
var len = match.Length;
|
||||
var intersect = false;
|
||||
foreach (var exist in _elements)
|
||||
{
|
||||
if (exist.Intersect(start, len))
|
||||
{
|
||||
intersect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (intersect)
|
||||
continue;
|
||||
|
||||
_elements.Add(new Models.InlineElement(Models.InlineElementType.Code, start, len, string.Empty));
|
||||
}
|
||||
|
||||
|
@ -187,7 +174,6 @@ namespace SourceGit.Views
|
|||
foreach (var rule in rules)
|
||||
rule.Matches(_elements, subject);
|
||||
|
||||
_elements.Sort((l, r) => l.Start - r.Start);
|
||||
_needRebuildInlines = true;
|
||||
InvalidateVisual();
|
||||
}
|
||||
|
@ -364,7 +350,7 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private List<Models.InlineElement> _elements = [];
|
||||
private Models.InlineElementCollector _elements = [];
|
||||
private List<Inline> _inlines = [];
|
||||
private Models.InlineElement _lastHover = null;
|
||||
private bool _needRebuildInlines = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue