[UX] Fix file tree sidebar: only expand current file path, O(1) tree-building #3

Merged
sleepy merged 1 commit from fix/1-file-tree-expand-perf into forgejo 2026-05-08 12:24:11 +02:00
Owner

Fixes

Expand bug: Folders now start collapsed except those on the path to currentTreePath. Uses parentPath prop and selfPath computed to determine if a folder is ancestor of current file.

Perf: Replaced O(n) Array.find() with O(1) Map lookup in tree-building. Integrated mergeChildIfOnlyOneDir into the main pass. Changed v-show to v-if for collapsed children.

Test Results

  • 29 test files, 138 tests passed (+9 new)
  • Lint clean, TS clean
## Fixes **Expand bug:** Folders now start collapsed except those on the path to `currentTreePath`. Uses `parentPath` prop and `selfPath` computed to determine if a folder is ancestor of current file. **Perf:** Replaced O(n) `Array.find()` with O(1) `Map` lookup in tree-building. Integrated `mergeChildIfOnlyOneDir` into the main pass. Changed `v-show` to `v-if` for collapsed children. ## Test Results - 29 test files, 138 tests passed (+9 new) - Lint clean, TS clean
fix: file tree sidebar expand perf and correct initial state
Some checks failed
requirements / merge-conditions (pull_request) Has been cancelled
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / semgrep/ci (pull_request) Has been cancelled
issue-labels / backporting (pull_request_target) Has been cancelled
milestone / set (pull_request_target) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (pull_request) Has been cancelled
testing / test-remote-cacher (redis) (pull_request) Has been cancelled
testing / test-remote-cacher (valkey) (pull_request) Has been cancelled
testing / test-remote-cacher (garnet) (pull_request) Has been cancelled
testing / test-remote-cacher (redict) (pull_request) Has been cancelled
testing / test-mysql (pull_request) Has been cancelled
testing / test-pgsql (pull_request) Has been cancelled
testing / test-sqlite (pull_request) Has been cancelled
testing / security-check (pull_request) Has been cancelled
ac85b0a5bb
Replace O(n) Array.find() with O(1) Map lookup in fileTree computed,
and integrate mergeChildIfOnlyOneDir into a bottom-up pass using the
map keys sorted by depth. Change v-show to v-if on sub-items container
to avoid keeping collapsed children in DOM.

Fix initial collapsed state to expand only folders on the path to the
current file (via currentTreePath), rather than expanding all folders
by default. Add parentPath prop to track recursive directory path.
sleepy merged commit 403f502b8d into forgejo 2026-05-08 12:24:11 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/forgejo!3
No description provided.