Repository navigation
search: open recently opened files under the folder's current location in Quick Open - #350128
Conversation
|
Base:
|
There was a problem hiding this comment.
🟡 Changes recommended
Quick Open can retain stale locations that open the wrong copy, and folder-location switches can strip typed history entries of their editor semantics.
2 open issues
What changed in this PR
Updates Quick Open’s recently opened results to follow the current location of a single local workspace folder, addressing stale worktree paths without changing editor history.
Changes:
- Caches folder locations and maps recent files to the current location.
- Groups mapped duplicates and removes all represented history entries when requested.
- Adds tests for path mapping, duplicate handling, opening, and removal.
| File | Description |
|---|---|
src/vs/workbench/contrib/search/test/browser/anythingQuickAccess.test.ts |
Adds folder-location mapping and history-action tests. |
src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts |
Adds location caching, history remapping, and grouped removal. |
Review effort: Balanced
063a30a
f4dca10 to
063a30a
Compare
Connor Peet (connor4312)
left a comment
There was a problem hiding this comment.
No blocking issues found. One non-blocking Quick Open selection issue is noted inline.
Written by Connor's agent
ecaabb1
…ck Open After switching a workspace folder's location (for example from a worktree back to the folder), Quick Open showed and opened the recently opened copies of files under the previous location. Entries under another known location of the folder are now shown and opened as the same relative path under the location the folder is at now, deduped with entries already there. The editor history itself is unchanged, and Remove from Recently Opened removes the original entry. Fixes #349761 Co-authored-by: Copilot <[email protected]>
When a recently opened file under another location of the folder is shown under the folder's current location, the row now keeps every history entry it collapses. Remove from Recently Opened removes all of them, and the row opens the folder's own entry where there is one. Map paths that differ from the location only in casing. Co-authored-by: Copilot <[email protected]>
…r search tests Quick Open now depends on IWorkspaceFolderLocationService; stub it in the tests that open the real provider. Co-authored-by: Copilot <[email protected]>
…ture Quick Open now depends on IWorkspaceFolderLocationService; the files empty state fixture opens the real provider when it searches. Co-authored-by: Copilot <[email protected]>
Refresh the active picker when folder location discovery finishes, and remap complete editor inputs without collapsing compound or custom editors into plain-file rows. Co-authored-by: Copilot <[email protected]>
When folder locations load after Quick Open shows results, the refresh no longer moves the focus to the first row. The picker keeps the pick with the same identity; Quick Open identifies a row by its editor id and its resource under the folder's current location, so a row remapped from a worktree still matches. Co-authored-by: Copilot <[email protected]>
On an onDidChangePicks refresh with fast and slow picks, the fast picks can reset the active pick to the first row before the slow picks arrive. When the slow picks are merged, the pick that was active before the refresh is now activated again, unless the user moved after the fast picks were applied. Co-authored-by: Copilot <[email protected]>
The fix for #349761 moves to a recently opened list per folder location, so Quick Open no longer maps entries of another location to the current one and no longer refreshes its picks when the locations load. Co-authored-by: Copilot <[email protected]>
Each folder location (the folder and each of its worktrees) now keeps its own list of recently opened editors. It is saved and restored together with the location's editor working set, so Quick Open at the folder no longer offers files that were opened in a worktree (#349761). The history service gets saveRecentlyOpened/restoreRecentlyOpened, sharing the serialization with its stored state. Co-authored-by: Copilot <[email protected]>
Clearing the recently opened editors now also drops the lists saved for the other locations of a folder, so they don't come back on the next switch. The lists are stored under their own key and only written when they change. Co-authored-by: Copilot <[email protected]>
Move the per-location recently opened list into the history service. On a change of the workspace folders, the list of each removed folder is put away under its folder URI and the list of each added folder is restored, so a Folder Location switch swaps the list atomically with the folder change. The workspace folders change event carries isFolderLocationChange. After a location switch (or a restart at another location), editors of the folder that was left are not added to the list. Folder location working sets go back to editors only, and the save/restore API on IHistoryService is removed. Co-authored-by: Copilot <[email protected]>
… restoring A diff of a folder that a location switch left stayed in the list and brought its sides back when it closed. Classify entries by their primary file, put a side-by-side editor away as its sides in that folder, and keep sides in a left folder out when it closes. Evict put away lists after restoring, so the list of an added folder is never evicted. Co-authored-by: Copilot <[email protected]>
Adding or removing folders of a multi-root workspace keeps the entries in the list, as before. On restart, the lists are swapped only in a single-folder workspace, where another folder can only be another location of it. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
6c92c24 to
bd7077e
Compare
Connor Peet (connor4312)
left a comment
There was a problem hiding this comment.
No blocking security or correctness issues found. I left two non-blocking correctness comments.
Written by Connor's agent

Fixes #349761
What
Switching Folder Location (for example from a worktree back to the folder) now also switches the recently opened list. The history service puts away the list of the location being left and restores the list it had for the location being entered, so Quick Open no longer offers the other location's copy of a file. A location visited for the first time starts with an empty list. Adding or removing folders of a multi-root workspace is unchanged. No setting.
Changes
IWorkspaceFoldersChangeEvent(workspace.ts): new optionalisFolderLocationChange, set by the configuration service (configurationService.ts) from the same flag it already passes toonWillChangeWorkspaceFolders.HistoryService(historyService.ts): on a Folder Location switch, puts away the recently opened entries of the removed folder under its URI and restores the entries put away for the added folder. An entry belongs to the closest folder, so a nested worktree keeps its own list. Diff and side-by-side editors are classified by their primary side and put away as their files.history.entries.putAway, capped at 20 folders, oldest put away evicted first), together with the folders the history was stored for, so a window that restarts at another location of its folder swaps the lists too.Notes for reviewers
onDidChangeLocationto the folder change event is Workbench components should react to workspace folder changes instead of onDidChangeLocation #350347.How to test
chat.editorWindow.enableWorktreeenabled, start a worktree chat session so the folder has a worktree location.src/app.tsin the worktree, switch Folder Location back to the folder and press Ctrl/Cmd+P: only the folder's files are listed, andapp.tsopens the folder's copy.Validation
./scripts/test.sh --reporter dot --run src/vs/workbench/services/history/test/browser/historyService.test.ts --grep 'per workspace folder': passed (11 tests; the new ones fail without the fix)./scripts/test.sh --reporter dotwithhistoryService.test.ts,configurationService.test.tsand every test file insrc/vs/workbench/services/editor/test/browser/: 604 passing, 7 pending (at bd7077e, rebased on main)pnpm run typecheck-client: passed at 3acb715e688; at bd7077e it reports errors only in Agent Host Copilot files because my local Copilot SDK install is older than main's, none in the changed filespnpm run oxlinton the changed files: passedchat.editorWindow.enableWorktreeon: switching from a chat-created worktree back to the folder, Cmd+P listed only the folder's files and its app.ts row opened the folder's copy; a pinned worktree diff did not show up at the folder; after a window reload at the worktree, each location kept its own list; Clear Recently Opened emptied both lists. All passed.Written by GitHub Copilot on behalf of Sandeep Somavarapu (@sandy081)