Skip to content

Reopen Closed Editor only reopens editors closed at the current folder location - #350575

Merged
Sandeep Somavarapu (sandy081) merged 5 commits into
mainfrom
agents/reopen-closed-editor-per-location
Nov 26, 2026
Merged

Sandeep Somavarapu (sandy081) merged 5 commits into
mainfrom
agents/reopen-closed-editor-per-location

Conversation

@sandy081

Copy link
Copy Markdown
Member

Fixes #350325

After a Folder Location switch, Reopen Closed Editor only reopens editors closed at the current location. Each location keeps its closed editors in memory for the window; switching back restores them. Editors the switch itself closes aren't recorded (new close context SWITCH). Deletes and moves keep the lists current.

Test: switch between a folder and its worktree, close editors at each, press Cmd+Shift+T.

Written by GitHub Copilot on behalf of Sandeep Somavarapu (@sandy081)

…ent folder location (#350325)

A folder location switch puts away the recently closed editors of the folder it
leaves, in memory only, and restores the ones put away for the folder it enters.
Editors that the switch closes are not recorded as recently closed. Deleting a
file also removes it from the put away lists.

Co-authored-by: Copilot <[email protected]>
…witch closes explicitly and follow moves (#350325)

- The folder location owner applies its working sets with the new
  switchesEditors option; editor parts report isSwitchingEditors while such
  an apply runs, including its fallback. History no longer infers switch
  closes from a workspace event followed by the next working-set apply.
- Each recently closed editor records the location where it was closed; a
  switch puts away and restores a location's list as a unit, and closing an
  editor only replaces its entry in the current location's list.
- Moves rewrite plain resource editors in the put away lists, drop the ones
  that cannot be rewritten, and move the list of a moved location.

Co-authored-by: Copilot <[email protected]>
…closes at any location, and key locations without trailing separators (#350325)

- New EditorCloseContext.SWITCH: applying a working set with switchesEditors
  closes its editors with that context (ICloseAllEditorsOptions.context),
  replacing the window-wide isSwitchingEditors state. History skips exactly
  those closes, so a user or other close while a switch apply is pending is
  still recorded.
- Reopen history no longer drops a user close because the editor's resource
  is in a folder that a switch left: it is recorded at the current location.
- Location keys drop trailing separators (root-aware), so a moved location
  root re-keys its put away list when the source or target has one.

Co-authored-by: Copilot <[email protected]>
… UNC share roots in location keys (#350325)

- IAuxiliaryEditorPart.close takes the close context: applying a working set
  that switches the editors passes SWITCH to the part's own close pass too, so
  an editor that the first pass skipped and that the part then closes is not
  recorded as recently closed.
- Location keys use the Folder Locations identity rule (now shared from
  platform/workspace/common/folderLocations.ts as withoutTrailingSeparator),
  which also folds the trailing separator of a UNC share root.

Co-authored-by: Copilot <[email protected]>
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.149.0 milestone Nov 26, 2026
Copilot AI balanced review requested due to automatic review settings November 26, 2026 16:41
…on whose list is active (#350325)

The workspace folder changes before its change is published. Closes in
between were deduplicated against the active list of the location being left
but tagged with the new folder. History now tracks the location of its
recently closed editors and only changes it when the change of the workspace
folders is published, together with the lists.

Co-authored-by: Copilot <[email protected]>

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

A Folder Location switch during a pending reopen batch can open remaining editors in the wrong location and lose their history entries, requiring cancellation, restoration, and regression coverage.

1 open issue
What changed in this PR

Makes Reopen Closed Editor specific to the current Folder Location, complementing the existing per-location open-editor and recently opened history.

Changes:

  • Saves and restores recently closed editors per location in memory, updating saved entries after moves and deletes.
  • Adds a SWITCH close context so working-set transitions do not count as user closes.
  • Adds tests for location isolation, path normalization, and close-context propagation.
File Description
src/​vs/​workbench/​services/​workspaces/​common/​workspaceFolderLocationService.ts Reuses the shared folder-path normalization helper.
src/​vs/​workbench/​services/​history/​test/​browser/​historyService.test.ts Tests per-location closed-editor history and file operations.
src/​vs/​workbench/​services/​history/​browser/​historyService.ts Stores and restores closed-editor history by location.
src/​vs/​workbench/​services/​editor/​test/​browser/​editorParts.test.ts Tests switch close contexts in main and auxiliary parts.
src/​vs/​workbench/​services/​editor/​common/​editorGroupsService.ts Adds switch and close-context options to editor contracts.
src/​vs/​workbench/​contrib/​workspaces/​browser/​folderLocationWorkingSets.ts Marks location working-set applications as editor switches.
src/​vs/​workbench/​common/​editor.ts Defines the SWITCH close context.
src/​vs/​workbench/​browser/​parts/​editor/​editorParts.ts Propagates switch context during working-set application.
src/​vs/​workbench/​browser/​parts/​editor/​editorPart.ts Passes close context through state restoration.
src/​vs/​workbench/​browser/​parts/​editor/​editorGroupView.ts Preserves close context when closing all editors.
src/​vs/​workbench/​browser/​parts/​editor/​auxiliaryEditorPart.ts Forwards close context when closing auxiliary parts.
src/​vs/​platform/​workspace/​common/​folderLocations.ts Exports shared trailing-separator normalization.

Review effort: Balanced

@sandy081
Sandeep Somavarapu (sandy081) marked this pull request as ready for review November 26, 2026 17:18
@sandy081
Sandeep Somavarapu (sandy081) added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit f952762 Nov 26, 2026
53 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/reopen-closed-editor-per-location branch November 26, 2026 21:44
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.

Reopen Closed Editor should be per folder location

4 participants