-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Avoid coloring moved lines #11947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Avoid coloring moved lines #11947
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review of first commit:
- test
CanGetAddedMovedDiffInfo
needs to be adapted
public override void AddTextHighlighting(IDocument document) | ||
=> document.MarkerStrategy.AddMarkers(_textMarkers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ Move to a base class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be TextHighlightService, but there are no textMerkers there.
So overridden in Diff (base), Grep and Difftastic.
|
||
namespace GitUI.Editor.Diff; | ||
|
||
public struct Segment : ISegment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a TextEditor interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one implementation in externals\ICSharpCode.TextEditor\Project\Src\Document\AbstractSegment.cs
Dis not use it due to the name.
The class is only used in this file.
The first commit does not detect / skip all moved lines. This is fixed up by the second commit. But the first commit should correctly handle all cases.
first commit 4aed061: second commit 30da54f: |
fixed (diff file was added as a displaycase for #119330 and I updated the file after your comments and missed to add this test to my playlist...)
I would rather squash the commits, there are too many changes that will not be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to split the PR after the second commit.
The second commit should remove ref found
from GetBlockOfLines
already.
maxLine
rather is endLine
.
public override bool IsSearchMatch(DiffViewerLineNumberControl lineNumbersControl, int indexInText) | ||
=> lineNumbersControl.GetLineInfo(indexInText)?.LineType is DiffLineType.Header; | ||
|
||
public override string[] GetFullDiffPrefixes() => _diffFullPrefixes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ Why move GetXxx
behind IsYyy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the order of functions (unchanged, other code in between was changed) or the IsSearch call (FileViewer uses that)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the order of functions
Yes, (GetGitCommandConfiguration
and) IsSearchMatch
should have been / be moved behind GetFullPrefixes
.
unchanged
Only visible in BC after manually matching the lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no change now
Can do that after #11862 is merged. |
755675e
to
d8e6ef8
Compare
Rebased on #11862 dropped the "gap" part (except the refactoring) and the cache part. |
dc68fcc
to
a03ef88
Compare
55f1758
to
b49e180
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Plan to squash and merge this in two days. |
Only parse the document for added/removed lines once, by using the DiffLineInfo info parsed for the linenumbering. Previously, the document was parsed many times every time the highlighting (including searching and marking) was changed. This simplifies the code.
Use heuristics to select which lines that are candidates to mark inlines for, avoid lines that Git has detected as moved lines.
0a9358a
to
58af311
Compare
Fixes #11843
Depends on #11862
Proposed changes
Use heuristics to select which lines that are candidates to
mark inlines for, avoid lines that Git has detected
as moved lines.
(the change is not complete, a few parts required from the second commit, to be squashed befor merge)
Only parse the document for added/removed lines once, by using
the DiffLineInfo info parsed for the linenumbering.
Previously, the document was parsed many times every time the
highlighting (including searching and marking) was changed.
This simplifies the code.
Test methodology
Some kind of tests will be added for the gap change, the other visible change has updated tests.
Merge strategy
Rebase
✒️ I contribute this code under The Developer Certificate of Origin.