feat(panel): improvements to multi-selection#46
Conversation
There was a problem hiding this comment.
Pull request overview
Adds persistence for Diffview file-panel selections across Neovim restarts by saving/restoring selections from a JSON store, along with configuration and an emitted User autocmd.
Changes:
- Introduces
diffview.selection_storeto load/save selections keyed by repo toplevel + revision args. - Wires the diff file panel to notify on selection changes and (when enabled) debounce persistence + emit
DiffviewSelectionChanged. - Adds
persist_selectionsdefaults/config docs and functional tests for the selection store + selection-change notifications.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/diffview/selection_store.lua | New JSON-backed selection store with scope keys and save/load. |
| lua/diffview/scene/views/diff/file_panel.lua | Adds selection-change callback hook and triggers it from selection-mutating methods. |
| lua/diffview/scene/views/diff/diff_view.lua | Initializes persistence (load + debounced save) and emits selection_changed event. |
| lua/diffview/init.lua | Converts selection_changed emitter event into User autocmd DiffviewSelectionChanged. |
| lua/diffview/config.lua | Adds persist_selections = { enabled = true, path = nil } default config. |
| doc/diffview_defaults.txt | Documents new default config entry. |
| doc/diffview.txt | Adds config help for persist_selections and documents DiffviewSelectionChanged. |
| lua/diffview/tests/functional/selection_store_spec.lua | Adds functional tests for store round-trips and selection-change notifications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @dlyongemallo, I really appreciate your work on diffview.nvim! It's an amazing plugin and I'm very grateful that you've implemented so many new features and fixes. With regard to the marking feature, I have a couple of comments that you might consider: Placing the mark (or a space) just in front of the file name changes the alignment and makes it more difficult to see which directory a file belongs to. Compare this image from original Diffview: And this image from your fork: The marks for directories are inserted only when necessary, so marking a directory leads to shifting the directory name to the right. I find this a little distracting. Maybe both issues (file alignment and directory shifting) could be solved by placing the selection marks to the very left of the lines (i.e., to the left of the modification types, something like this: Then the whole tree could be shifted if any file was marked. Also, maybe the mark characters could be customizable, I'd actually like to make them a little more prominent and maybe use something like ⬜ and ✅. |
Optionally saves selections to a JSON file scoped by repo toplevel and rev
args (defaults to `stdpath("data")/diffview_selections.json`).
Adds new config: `persist_selections = { enabled = false, path = nil }`.
Adds new User autocmd: `DiffviewSelectionChanged`.
db6276c to
027e260
Compare
|
@jakubbortlik I've made the selection marks customisable but the problem with your suggested characters is that they don't render consistently across terminals. In particular, they render with different widths depending on the environment. You can try the following and see how they appear for you: require("diffview").setup({
signs = {
selected_file = "✅",
unselected_file = "⬜",
selected_dir = "✅",
partially_selected_dir = "🔳",
unselected_dir = "⬜",
},
file_panel = {
always_show_marks = true,
},
}) |
|
@dlyongemallo, thanks for implementing this! This is a very useful feature. I'm aware that the unicode characters I've mentioned are problematic and the customization in the settings is ideal for me. I still think placing the marks to the very left would make the tree more clean, but I guess I will get used to the current state. |



Allow selection marks to be customised. Remaps default keys:
spaceto toggle selection,Cto clear all.Optionally saves selections to a JSON file scoped by repo toplevel and rev args (defaults to
stdpath("data")/diffview_selections.json).Relates to sindrets#582.