Skip to content

Add setting to keep unavailable entries in recently opened list - #325342

Open
Victor Irzak (virzak) wants to merge 1 commit into
microsoft:mainfrom
virzak:fix/keep-unavailable-recents
Open

Add setting to keep unavailable entries in recently opened list#325342
Victor Irzak (virzak) wants to merge 1 commit into
microsoft:mainfrom
virzak:fix/keep-unavailable-recents

Conversation

@virzak

Copy link
Copy Markdown

Fixes #164491

Problem

VS Code silently removes entries from the "Recently Opened" list whenever their path cannot be accessed. For users whose folders live on drives that are only temporarily unavailable (e.g. subst-mapped drives that are not yet mapped at startup, removable media, network shares), this permanently loses history that would be perfectly valid a minute later.

Change

Adds a new setting, window.removeRecentEntriesWhenUnavailable (boolean, default true, application scope). The default preserves existing behavior; setting it to false keeps unavailable entries in the list.

Two removal sites are gated behind the setting:

  • WindowsMainService.doResolveFilePath: removed an entry whenever fs.stat on its path threw. This is the code path that fires at startup when restoring windows and when opening a recent entry, and it covers folders, workspace files, and files alike.
  • Menubar.createOpenRecentMenuItem: removed an entry when opening it from File > Open Recent failed.

Explicit user removals (the "Remove from Recently Opened" buttons) and removal on actual file-delete operations in HistoryService are intentionally left untouched, since those are genuine deletions rather than temporary unavailability. The "Path does not exist" dialog still shows when opening an unavailable entry; the only change is that the entry survives to be opened later.

Testing

  • tsc --noEmit on src/tsconfig.json passes.
  • Manually verified on Windows by building from source and reproducing the issue scenario with a subst drive (isolated --user-data-dir/--shared-data-dir, inspecting the persisted history.recentlyOpenedPathsList after each run):
    • default setting, drive unmapped, relaunch: entry removed (existing behavior preserved)
    • setting false, drive unmapped, relaunch: entry kept, and the folder opens normally once the drive is mapped again

🤖 Generated with Claude Code

https://claude.ai/code/session_01MEcyivcz7hSfwq7H4DPkBz

…#164491)

Adds window.removeRecentEntriesWhenUnavailable (default true). When
disabled, entries whose path is currently inaccessible (e.g. a subst or
removable drive that is not mounted yet) are no longer pruned from the
recently opened list at startup or when opening them fails.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MEcyivcz7hSfwq7H4DPkBz
Copilot AI review requested due to automatic review settings July 10, 2026 18:21

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.

Pull request overview

Adds an application setting to preserve temporarily unavailable entries in the recently opened list while retaining existing behavior by default.

Changes:

  • Registers window.removeRecentEntriesWhenUnavailable.
  • Gates automatic removal during path resolution and recent-menu opening.
  • Extends IWindowSettings with the new option.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/vs/workbench/electron-browser/desktop.contribution.ts Registers the setting.
src/vs/platform/windows/electron-main/windowsMainService.ts Gates removal after path-resolution failures.
src/vs/platform/window/common/window.ts Adds the setting type.
src/vs/platform/menubar/electron-main/menubar.ts Gates removal after recent-menu failures.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a setting to not remove files from recently opened that cannot open

3 participants