fix(panel): preserve selections and folder state across tab switches#45
Merged
dlyongemallo merged 1 commit intomainfrom Mar 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR preserves file selections and directory fold states across tab switches and file list refreshes in the diffview panel. Previously, selections were keyed by object identity and cleared on every update; now they use stable string keys (kind:path) and are pruned rather than cleared.
Changes:
- Selections now use stable
kind:pathstring keys instead of object identity, withprune_selections()replacingclear_selections()on file updates - Directory collapsed state is propagated to underlying tree nodes via
set_dir_collapsed(), fixing flattened directory state persistence;_nodein flattened dirs now points to the outermost node - New configurable signs for selected files/dirs and directory selection state rendering in the panel
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lua/diffview/scene/views/diff/file_panel.lua | Add stable selection keys, select_file/deselect_file/prune_selections/dir_selection_state/set_dir_collapsed methods |
| lua/diffview/scene/views/diff/listeners.lua | Use new selection/collapse APIs; suppress highlight on tab enter; prune instead of clear |
| lua/diffview/scene/views/diff/diff_view.lua | Three-valued highlight parameter (true/false/nil); pass nil instead of false on update |
| lua/diffview/scene/views/diff/render.lua | Thread conf through render functions; render dir selection indicators |
| lua/diffview/ui/models/file_tree/file_tree.lua | Fix _node to point to flatten root in flattened directory chains |
| lua/diffview/config.lua | Add selected_file, selected_dir, partially_selected_dir sign defaults |
| doc/diffview.txt | Document new signs and updated selection behavior |
| doc/diffview_defaults.txt | Add new sign defaults |
| lua/diffview/tests/functional/panel_spec.lua | Comprehensive tests for new selection and collapse behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fe0f414 to
b1666fe
Compare
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.
Partially relates to sindrets#582.