Scope EditorTabsVisibleContext to editor parts for correct action resolution#299261
Merged
Scope EditorTabsVisibleContext to editor parts for correct action resolution#299261
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect action visibility in the modal editor by scoping EditorTabsVisibleContext to each EditorPart's own scopedContextKeyService, rather than relying solely on the global context key derived from the main editor part. Without this fix, when the modal editor enforces showTabs: 'none' or 'single', actions gated on EditorTabsVisibleContext.toNegated() (e.g. close/unpin buttons in the title bar) would resolve incorrectly because the global key still reflected the main window's tab setting.
Changes:
- Bind
EditorTabsVisibleContexttoEditorPart.scopedContextKeyServiceinhandleContextKeys(), matching the existing pattern forEditorPartMultipleEditorGroupsContextandEditorPartMaximizedEditorGroupContext. - Add a listener on
onDidChangeEditorPartOptionsto keep the per-part scoped value in sync when options change (including enforced overrides). - Add a test in
editorGroupsService.test.tsto verify the scoped context key correctly reflects enforcedshowTabsvalues.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/vs/workbench/browser/parts/editor/editorPart.ts |
Adds scoped binding + listener for EditorTabsVisibleContext in handleContextKeys() |
src/vs/workbench/services/editor/test/browser/editorGroupsService.test.ts |
New test verifying context key updates with enforced showTabs values |
src/vs/workbench/services/editor/test/browser/editorGroupsService.test.ts
Outdated
Show resolved
Hide resolved
…ice.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
dmitrivMS
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the modal editor part enforces
showTabs: 'multiple'(or'none'), theEditorTabsVisibleContextwas only set globally based on the main editor part's options. This caused close/unpin actions gated onEditorTabsVisibleContext.toNegated()to incorrectly appear in the modal editor when the user had tabs configured as'single'globally.Fix: Bind
EditorTabsVisibleContexttoEditorPart.scopedContextKeyServiceinhandleContextKeys(), matching the existing pattern forEditorPartMultipleEditorGroupsContextandEditorPartMaximizedEditorGroupContext. The scoped value overrides the global one within each editor part's DOM subtree, so actions resolve correctly against the enforced options.Consumers of this context key (all in
editor.contribution.ts):when: EditorTabsVisibleContext.toNegated()when: EditorTabsVisibleContext.toNegated()when: EditorTabsVisibleContext