Skip to content

Tree explorer flattening becomes inconsistent after staging/unstaging nested entries #327

@richardgill

Description

@richardgill

Summary

When view_mode = "tree" and flatten_dirs = true, staging or unstaging nested entries with s causes the explorer to rebuild the same path with a different flattened shape across groups.

Reproduction

  1. Create a repo with modified files in nested paths, for example:
    • src/alpha/one/a.txt
    • src/alpha/one/b.txt
    • src/alpha/two/c.txt
    • src/beta/gamma/d.txt
    • docs/guide/readme.md
  2. Open :CodeDiff with tree view enabled.
  3. In Changes, move to src/alpha/one and press s.
  4. Observe the explorer.
  5. In Staged Changes, move to src/alpha/one and press s again.

Actual

After staging, the same directory hierarchy is flattened differently across groups. For example:

  • Changes shows src with alpha/two under it
  • Staged Changes shows src/alpha/one as a single flattened top-level node

The hierarchy jumps as files move between Changes and Staged Changes.

Expected

The explorer tree should keep a stable directory shape when entries move between groups.

I put together an AI-generated fix here: #328

Environment

  • codediff.nvim commit: 93cd80c56f71af4671388c568a37d4c84c3ddefa
  • Neovim: v0.11.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions