diffview-plus.nvim icon indicating copy to clipboard operation
diffview-plus.nvim copied to clipboard

[Bug] staging/unstaging a file opens folds

Open nathanzeng opened this issue 1 month ago • 5 comments

Description

Staging or unstaging a file opens folds.

22a293181f6132d175efbbf279c251d7f01d1e8b is the first 'bad' commit (per git bisect)

Expected behavior

Staging or unstaging a file does not affect folds.

Actual behavior

https://github.com/user-attachments/assets/8e8984e2-3947-40f0-a5c6-c2fdc46035bf

Steps to reproduce

  1. Use the following 1-line init.lua
vim.pack.add({ "https://github.com/dlyongemallo/diffview-plus.nvim" })
  1. Got to a repo that has a bunch of git changes
  2. Start nvim and then :DiffviewOpen
  3. Move your cursor onto a fold, and then stage or unstage with s from the file panel

Health check

Output of :checkhealth diffview
diffview:                                                                   ✅

Checking icon provider ~
- No icon provider found (nvim-web-devicons or mini.icons). Icons will be disabled; set `use_icons = false` to silence this.

Checking VCS tools ~
- The plugin requires at least one of the supported VCS tools to be valid.
- ✅ OK Git is up-to-date. (2.56.0)

Log info

Relevant info from :DiffviewLog
############################
### PUT LOG CONTENT HERE ###
############################

Neovim version

12.6

Operating system and version

Fedora 44

Minimal config


nathanzeng avatar Oct 25 '26 19:10 nathanzeng

22a293181f6132d175efbbf279c251d7f01d1e8b is the first 'bad' commit

nathanzeng avatar Oct 25 '26 19:10 nathanzeng

@seflue @dlyongemallo Looks like this happens when the cursor is placed in a fold. I updated the reproductions steps to specify that.

I also vibe-coded a PR in my fork here in case that's helpful for reference: https://github.com/nathanzeng/diffview.nvim-fork/pull/1

nathanzeng avatar Nov 01 '26 18:11 nathanzeng

When the cursor is in a fold this is actually intended. But only to unfold where the cursor is, not to open all folds.

seflue avatar Nov 01 '26 19:11 seflue

For the way I use diffview plus, I don't think I ever want to unfold. Would you consider supporting that via configuration or as a default?

nathanzeng avatar Nov 02 '26 02:11 nathanzeng

@nathanzeng @dlyongemallo I opened a PR (#375). The mistake was, that the way, the cursor is handled during browsing through file revisions - especially the folding - was also applied in other cases. The reason why I added it for revision browsing: When I step through revision of a file, I am interested in the development of a certain code section. This is why I want to keep the cursor position (it is a best guess) and when the cursor lands in a fold, I want to see the code immediately. But this behavior doesn't make sense when switching between different files and the bug was the missing constrain.

seflue avatar Nov 02 '26 08:11 seflue