Skip to content

[Bug] staging/unstaging a file opens folds #371

Closed

Description

@nathanzeng

Description

Staging or unstaging a file opens folds.

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

Expected behavior

Staging or unstaging a file does not affect folds.

Actual behavior

2026-10-25.12-11-04.mp4

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

Activity

  1. nathanzeng commented on Oct 25, 2026

    @nathanzeng
    Author

    22a2931 is the first 'bad' commit

  2. nathanzeng commented on Nov 1, 2026

    @nathanzeng
    Author

    @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: nathanzeng#1

  3. seflue commented on Nov 1, 2026

    @seflue

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

  4. nathanzeng commented on Nov 2, 2026

    @nathanzeng
    Author

    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?

  5. seflue commented on Nov 2, 2026

    @seflue

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions