Skip to content

fix(panel): preserve selections and folder state across tab switches#45

Merged
dlyongemallo merged 1 commit intomainfrom
preserve_selections_and_fold_state
Mar 17, 2026
Merged

fix(panel): preserve selections and folder state across tab switches#45
dlyongemallo merged 1 commit intomainfrom
preserve_selections_and_fold_state

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

Partially relates to sindrets#582.

Copilot AI review requested due to automatic review settings March 17, 2026 04:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:path string keys instead of object identity, with prune_selections() replacing clear_selections() on file updates
  • Directory collapsed state is propagated to underlying tree nodes via set_dir_collapsed(), fixing flattened directory state persistence; _node in 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.

Comment thread doc/diffview.txt Outdated
@dlyongemallo dlyongemallo force-pushed the preserve_selections_and_fold_state branch from fe0f414 to b1666fe Compare March 17, 2026 05:06
@dlyongemallo dlyongemallo merged commit 542a194 into main Mar 17, 2026
2 checks passed
@dlyongemallo dlyongemallo deleted the preserve_selections_and_fold_state branch March 17, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants