Repository navigation
Open folds only when stepping through a file's revisions - #375
Merged
Merged
Conversation
The cursor carry is meant for browsing the revisions of one file and nothing else. Opening the fold under the restored cursor also ran on every other restore, such as after staging or when switching back to a file. It now runs only on a step to another revision. Fixes dlyongemallo#371
|
Tried this out on my machine and it fixes #371 for me! |
There was a problem hiding this comment.
🟡 Changes recommended
Fold-reveal state can be replayed through rename aliases, and refreshed entries for the same commit can incorrectly open folds without a revision change.
2 open issues
What changed in this PR
This PR narrows cursor-reveal behavior to revision navigation in file history, addressing unwanted fold opening after staging or switching files while preserving cursor carry from #314.
Changes:
- Gates fold opening on same-file revision steps, including renames.
- Enables revision-step detection for file-history views.
- Adds tests for closed-fold restoration and revision-step classification.
| File | Description |
|---|---|
lua/diffview/tests/functional/cursor_carry_spec.lua |
Tests fold preservation, cursor reveal, and revision-step detection. |
lua/diffview/scene/views/standard/standard_view.lua |
Adds revision-step detection and conditional fold reveal during cursor restoration. |
lua/diffview/scene/views/file_history/file_history_view.lua |
Enables revision-step behavior for file history. |
Review effort: Balanced
Comment on lines
+84
to
+87
| if not to or to == from then | ||
| return false | ||
| end | ||
| return to.path == from.path or alias ~= nil |
Comment on lines
+361
to
+363
| if target.reveal then | ||
| reveal_cursor_line(win.id) | ||
| end |
Owner
|
Thanks @seflue for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #371
The cursor carry from #314 is meant for browsing the revisions of one
file and nothing else. Opening the fold under the restored cursor also
ran on every other restore, such as after staging or when switching
back to a file. It now runs only when the next entry is another
revision of the same file in the file history, including across a
rename.
A new spec restores a cursor left on a closed fold and checks that the
fold stays closed. The existing file history spec still checks that a
step opens the fold hiding the carried line.