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
- 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
- Open
:CodeDiff with tree view enabled.
- In
Changes, move to src/alpha/one and press s.
- Observe the explorer.
- 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
Summary
When
view_mode = "tree"andflatten_dirs = true, staging or unstaging nested entries withscauses the explorer to rebuild the same path with a different flattened shape across groups.Reproduction
src/alpha/one/a.txtsrc/alpha/one/b.txtsrc/alpha/two/c.txtsrc/beta/gamma/d.txtdocs/guide/readme.md:CodeDiffwith tree view enabled.Changes, move tosrc/alpha/oneand presss.Staged Changes, move tosrc/alpha/oneand presssagain.Actual
After staging, the same directory hierarchy is flattened differently across groups. For example:
Changesshowssrcwithalpha/twounder itStaged Changesshowssrc/alpha/oneas a single flattened top-level nodeThe hierarchy jumps as files move between
ChangesandStaged 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
93cd80c56f71af4671388c568a37d4c84c3ddefav0.11.4