Skip to content

Scope EditorTabsVisibleContext to editor parts for correct action resolution#299261

Merged
bpasero merged 3 commits intomainfrom
ben/copilot/teenage-clownfish
Mar 4, 2026
Merged

Scope EditorTabsVisibleContext to editor parts for correct action resolution#299261
bpasero merged 3 commits intomainfrom
ben/copilot/teenage-clownfish

Conversation

@bpasero
Copy link
Member

@bpasero bpasero commented Mar 4, 2026

When the modal editor part enforces showTabs: 'multiple' (or 'none'), the EditorTabsVisibleContext was only set globally based on the main editor part's options. This caused close/unpin actions gated on EditorTabsVisibleContext.toNegated() to incorrectly appear in the modal editor when the user had tabs configured as 'single' globally.

Fix: Bind EditorTabsVisibleContext to EditorPart.scopedContextKeyService in handleContextKeys(), matching the existing pattern for EditorPartMultipleEditorGroupsContext and EditorPartMaximizedEditorGroupContext. 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):

  • Close button (normal/dirty editor) — when: EditorTabsVisibleContext.toNegated()
  • Unpin button (sticky/dirty+sticky) — when: EditorTabsVisibleContext.toNegated()
  • "Close to the Right" context menu — when: EditorTabsVisibleContext

Copilot AI review requested due to automatic review settings March 4, 2026 19:00
@bpasero bpasero self-assigned this Mar 4, 2026
@bpasero bpasero added this to the 1.111.0 milestone Mar 4, 2026
@bpasero bpasero enabled auto-merge (squash) March 4, 2026 19:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 EditorTabsVisibleContext to EditorPart.scopedContextKeyService in handleContextKeys(), matching the existing pattern for EditorPartMultipleEditorGroupsContext and EditorPartMaximizedEditorGroupContext.
  • Add a listener on onDidChangeEditorPartOptions to keep the per-part scoped value in sync when options change (including enforced overrides).
  • Add a test in editorGroupsService.test.ts to verify the scoped context key correctly reflects enforced showTabs values.

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

bpasero and others added 2 commits March 4, 2026 20:05
…ice.test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bpasero bpasero merged commit fdceca1 into main Mar 4, 2026
20 checks passed
@bpasero bpasero deleted the ben/copilot/teenage-clownfish branch March 4, 2026 20:20
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.

3 participants