mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 05:57:38 -04:00
When a single file is modified inside a nested directory, the file tree compresses the whole chain of directories into one line, such as "pkg/gui/controllers/helpers". Selecting that line shows the diff of the entire working tree. When a second file is then modified in another subdirectory of pkg/gui, the tree splits the line into "pkg/gui" with "context" and "controllers/helpers" below it, and the refresh moves the selection down to "controllers/helpers". Users who keep the top directory selected to see the diff of everything lose that view and have to move the cursor back up after every such refresh. This happens because the selection is re-found by the node's own path, and a compressed node's path is the deepest directory in its chain. The node stood for every directory in that chain, though, and the topmost piece of the split is the one that stays on the same line. Match a compressed directory node against any new node that stands for at least one of the same directories. The list is in depth-first order, so the topmost piece wins and the cursor stays on its line. Files are never compressed, so their handling doesn't change. The reverse case, where two directories fold back into one compressed line, already selected the merged line and still does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>