Skip to content

Workbench components should react to workspace folder changes instead of onDidChangeLocation #350347

Todo

Description

When a single-folder window switches Folder Location, the workspace folder URI changes, and IWorkspaceContextService.onDidChangeWorkspaceFolders fires with the old folder removed and the new one added. With #350128, that event also says the change was a Folder Location switch (isFolderLocationChange). Today several components react to IWorkspaceFolderLocationService.onDidChangeLocation instead: editor working sets, search, outline, terminal and others. So they behave differently for a location switch than for a multi-root add or remove, and they depend on the location service even though the generic folder change already covers it. #350128 moved the recently opened history to the folder change event.

Proposal: move these components to onDidChangeWorkspaceFolders, using isFolderLocationChange where they need to tell a location switch apart, and keep onDidChangeLocation only for location UI (the status bar entry, the location pill and the location picker).

Note: onWillChangeWorkspaceFolders currently fires after getWorkspace() already returns the new folders, because the configuration service updates the workspace first. A component that wants to save state for the folder being left can't rely on getWorkspace() in that event. This should be fixed or documented as part of the move.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debt

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions