Repository navigation
fix: keep the folders a reader closed in a file tree when its paths change - #5937
Merged
Merged
Conversation
…hange lf-file-tree builds its Trees model with `initialExpansion: "open"`, and `resetPaths` builds a fresh store from that option, which opens every folder whatever `initialExpandedPaths` lists. So the list the widget passed there never changed the result: a folder the reader closed reopened at the next update to the file list. The widget kept that list current by reading every visible row on each model emit, which Trees fires on every arrow key and every letter typed in search, so each of those inputs cost a pass over the expanded tree. Now the model listener reads no rows. At a path change the widget reads which folders are closed from the old model and closes them again in the new one; every other folder, a new one included, opens as before. Behavior changed: a folder the reader closed stays closed across a change to the tree's paths (test_file_tree_keeps_the_folders_the_reader_closed_when_its_paths_change).
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an
lf-file-tree's paths change, a folder the reader closed now stays closed. Before this, it reopened at every update to the file list. The model listener also stops reading every visible row, which it did on each arrow key and each letter typed in search.Cause. The widget builds its Trees model with
initialExpansion: "open".resetPathsbuilds a new store from that option, which opens every folder whateverinitialExpandedPathslists. I checked this against the vendored@pierre/trees1.0.0-beta.6 by callingFileTreeController.resetPathswith an empty list, then with one folder: both times every folder came back open. So the expansion list the widget kept, and handed toresetPaths, never changed the result.The widget kept that list current in a
tree.subscribelistener. It calledgetVisibleRows(0, getVisibleCount() - 1), which builds a row object for every visible row. Trees fires that listener on every focus move, search keystroke and selection, so the cost of each input grew with the tree. RootAGENTS.md's Responsiveness rules that out.Change. The listener now only repaints the empty state and refreshes commands. At a path change, the widget reads which folders are closed from the old model and closes them again after
resetPaths. Every other folder opens as before, new ones included. The module header now states what an update keeps.Verification.
test_file_tree_keeps_the_folders_the_reader_closed_when_its_paths_change: it fails onmain(srcreadsaria-expanded="true"after the update) and passes here.-k "file_tree".pnpm run check:browserpasses.Found by the nightly survey of
packages/file-tree/widgets/lf-file-tree.js.