Skip to content

search: open recently opened files under the folder's current location in Quick Open - #350128

Merged
Sandeep Somavarapu (sandy081) merged 14 commits into
mainfrom
agents/quick-open-current-location
Nov 26, 2026
Merged

Sandeep Somavarapu (sandy081) merged 14 commits into
mainfrom
agents/quick-open-current-location

Conversation

@sandy081

@sandy081 Sandeep Somavarapu (sandy081) commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

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 optional isFolderLocationChange, set by the configuration service (configurationService.ts) from the same flag it already passes to onWillChangeWorkspaceFolders.
  • 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.
  • While at the new location, editors under the location that was left (for example still open during a deferred switch) aren't added to the list, including when a diff editor is closed later.
  • The put-away lists are stored in the workspace storage (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.
  • Clear Recently Opened and Clear Editor History also clear the put-away lists.

Notes for reviewers

How to test

  1. In a single-folder window with chat.editorWindow.enableWorktree enabled, start a worktree chat session so the folder has a worktree location.
  2. Open some files at the folder, then switch Folder Location to the worktree: Ctrl/Cmd+P shows no recently opened files.
  3. Open src/app.ts in the worktree, switch Folder Location back to the folder and press Ctrl/Cmd+P: only the folder's files are listed, and app.ts opens the folder's copy.
  4. Switch back to the worktree: its list returns. Run Clear Recently Opened, then switch locations: both lists are empty.

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 dot with historyService.test.ts, configurationService.test.ts and every test file in src/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 files
  • pnpm run oxlint on the changed files: passed
  • Live check in Code OSS from sources at 3acb715e688 (same change as bd7077e before the rebase), in an isolated profile with chat.editorWindow.enableWorktree on: 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)

@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.149.0 milestone Nov 24, 2026
Copilot AI balanced review requested due to automatic review settings November 24, 2026 12:00
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Base: ae408942 Current: b14a7b87

No screenshot changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found. One non-blocking Quick Open selection issue is noted inline.

Written by Connor's agent

…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]>
@sandy081
Sandeep Somavarapu (sandy081) force-pushed the agents/quick-open-current-location branch from 6c92c24 to bd7077e Compare November 25, 2026 22:08
@sandy081
Sandeep Somavarapu (sandy081) marked this pull request as ready for review November 25, 2026 22:09

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking security or correctness issues found. I left two non-blocking correctness comments.

Written by Connor's agent

Merged via the queue into main with commit 7d76954 Nov 26, 2026
53 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/quick-open-current-location branch November 26, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick Open defaults to the previous worktree copy of a file after switching folder location

9 participants