-
Notifications
You must be signed in to change notification settings - Fork 147
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
Add navigation and highlighting of change-blocks in Text Diff (#616, #717) #703
base: develop
Are you sure you want to change the base?
Conversation
I'm very sorry. After checked your implementation, I think we should use another implementation because:
I'd like to implement this feature by just modify
I'll try to implement this by myself later. |
@love-linger I see. And yes, my change-blocks could be chunks/hunks instead, as long as they are well-defined and can be counted. However:
This is how the major Diff/Merge tools out there implement prev/next. My implementation was a slight simplification / first effort since it does not (yet) track when Caret moves to another change-block (instead it only moves the Caret when navigating, so change-block <-> Caret interaction is essentially one-way). Also, I did not add keyboard shortcuts yet, but that should definitely be added in a later PR to make this VERY useful. (Using the mouse is not the fastest possible workflow) Ideally, in future we should also display "current / total" number of change-blocks and have "first / last" navigation as well. , similar to this screenshot from the Plastic SCM Mergetool (which is what I come from and am used to) : |
I still insist that when we click the previous or next button, we should find the target change directly from the first or last line of the current page, rather than by the current Caret position.
|
I've pushed my implementation of this feature. |
cd946d2
to
c772545
Compare
New StreamGeometry "Icons.Diff.Prev" / "Icons.Diff.Next" using SVG paths from "arrow_up_regular" / "arrow_down_regular" at https://avaloniaui.github.io/icons.html.
These new buttons in DiffView toolbar are visible when IsTextDiff. They invoke new (and currently empty) methods PrevChange() / NextChange() in DiffContext.
I.e when unset or already at first/last change-block (or the only one).
…iff view (sourcegit-scm#616) Signed-off-by: leo <longshuang@msn.cn> (cherry picked from commit 134c710) # Conflicts: # src/Views/DiffView.axaml # src/Views/TextDiffView.axaml.cs
This reverts commit 1f8dc29.
bd9896d
to
57e147e
Compare
@love-linger Thank you, but your pushed implementation does not help me much. It's basically an enhanced page-up/down that knows about changes. I could easily lose track and miss changes by using that implementation, since there is no highlighting. What I want is a much more exact tracking of the change-blocks (ideally with the "current / total" numbers visible) and with the kind of highlighting I implemented, so that I can really step through each one and review them. (Thus, in my opinion, navigating change-blocks within visual lines is still crucial.) Also, my change-blocks were not based on your Hunk detection. Instead it uses the kind of change-blocks used in most external Diff/Merge tools, where "unchanged lines break the sequence" - that definition is very simple. (The two implementations should be able to coexist without interfering, since the Hunk interactions are based on mouse hover and can be overlayed on top of the change-block highlight.) I do not view Caret tracking as crucial for now, and I have no issue with the Diff view being read-only. (Although future edit functionality - as in Plastic SCM's Pending Changes view - would be awesome!) |
NOTE: I rebased and updated the branch in my fork to adjust to your changes on @love-linger Just curious - did you actually run my implementation to try it out, or did you just review the code? |
I just read your code. |
@love-linger It would be nice if you at least tried it out, to make sure you understand the kind of highlighting and navigation I'm looking for. 🥺 (I could re-enable my implementation on my rebased branch, so you can try it.) |
I've tried your implementation. As I said, when we click the previous or next button, we should find the target change directly from the first or last line of the current page. If you have scrolled the highlighted block out of current page manually. The next time you click the prev or next button, it will always starts from the last highlighted block, just like back-scroll. And user can not change the hightlighted block in any other ways. |
@love-linger I'm not sure I understand your point. In my implementation, the thing missing right now is the display of counters "current / total" which would make it more clear even if you've scrolled the highlighted block out of view. I could add that too. I find it super useful to be able to see at a glance how many changes there are in a file, and to step through them in a very controlled manner like this (while highlighting the current one). Could we at least make this an optional feature? |
for example: there are 5 blocks and each block taking a single page and you're currently highlighting the 1st block (at the first page). then you scroll (or use page down) to the 4th page where the 4th change block exists. when you click the next button, the expected block is 5th.
|
@love-linger I see what you mean - but scroll and (Pg)Up/Dn etc are actually different, since scroll does not move Caret while (Pg)Up/Dn does (same for clicking to place Caret etc). The way Plastic SCM Mergetool handles this quite elegantly is to track Caret but not scroll. I.e. moving the Caret will modify the highlight and "current / total" display, while scrolling won't. So navigating to prev/next change will always be based on the "current" number. If we add the "current / total" numbers display it would IMHO become clearer, even without tracking Caret which can be added later as an enhancement. |
I will think about it carefully tomorrow.
At present, the available space in the toolbar is very tight. It is not recommended to add too many functions. Including this feature, it has been implemented in the early version, and was deleted after adding support for external diff tool
|
@love-linger Thank you. Meanwhile, I added a "current / total" numbers display in the toolbar, to illustrate my reasoning. |
Added a bool property DiffView.UseChangeBlocks. It's not bound from UI yet, but could be used for runtime switching between the two different implementations of prev/next change. The buttons are now using the OnGoto[Prev|Next]Change Click-handler, regardless of implementation.
BTW: if needed, horizontal space in the Diff toolbar could be regained by moving "toggle" options into a dropdown. Also, I usually go for a two-sided diff - then the side-by-side diff panes themselves need more horiz space than the toolbar buttons do... |
@love-linger I fully understand your preference when it comes to navigation, it's just not the way I prefer to work. If you look at P4Merge, WinMerge and others they do navigation within the displayed content, but I should not have to resort to external tools for that - it would mean extra clicks and loading times for EACH file, which slows down workflow greatly. In my PR I've begun providing the means for making this a preference option. Your implementation could be the default, and the current/total numbers indicator can be hidden in that case. |
Besides, being able to see at a glance a number (current/total) of how many change-blocks there are in a Diff is IMHO a great feature in itself (slightly related to #647). |
To summarize: I would use the external diff tool only for merge-conflict resolution (4-way merge) and for especially complex diffs, but for daily routine Diff I would use the built-in Diff since it's much faster to work that way. Therefore, the built-in Diff has to cover the basic needs of my workflow, which revolves around being able to step through and highlight each change-block for review before commit (usually in a side-by-side Diff view). If I'm not able to step through multiple blocks on a single screen/page, I might lose track and miss a change. I'm using the current/total numbers to see how many blocks there are and where I'm at while reviewing the changes. I'm fine with having this as an optional workflow feature, that can be turned on via Preferences. |
Related issues:
Status:
develop
branch (134c710, 882878d).Quick feature overview:
Detailed summary of changes:
Text.Diff.Prev
,Text.Diff.Next
).