modal - improve handling of Escape key and expand use of modal editors to more kinds#299060
Open
modal - improve handling of Escape key and expand use of modal editors to more kinds#299060
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Expands modal editor usage to additional preferences-related editors and refines Escape handling for modal editor close behavior via keybindings (instead of ad-hoc DOM handling).
Changes:
- Preferences/keybindings/settings JSON editors now choose the modal editor group whenever
workbench.editor.useModalis enabled. - Modal editor Escape-to-close handling is moved from a dedicated DOM
Escapelistener to command/keybinding rules with focus-sensitive precedence. - Close Modal Editor keybinding is split into two
Escaperules to adjust priority depending on whether a text editor is focused.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/vs/workbench/services/preferences/browser/preferencesService.ts |
Routes more preferences editors (including JSON/textual variants) into the modal editor group when modal mode is enabled. |
src/vs/workbench/browser/parts/editor/modalEditorPart.ts |
Removes custom Escape close logic; relies on command/keybinding handling and keeps command filtering logic. |
src/vs/workbench/browser/parts/editor/editorCommands.ts |
Updates the modal close command to use two Escape keybindings with different weights based on editor focus. |
Comments suppressed due to low confidence (1)
src/vs/workbench/services/preferences/browser/preferencesService.ts:383
getEditorGroupFromOptionsnow returnsMODAL_GROUPwheneverworkbench.editor.useModalis notoff, which means explicit targeting options likeopenToSide/groupIdare ignored even for JSON settings/keybindings editors. Previously the JSON settings path (and the textual keybindings path) could still honoropenToSide/groupIdunderuseModal: 'some'. Consider prioritizing explicitopenToSide/groupIdover modal (or introducing an explicit flag to force modal) to avoid breaking callers that pass these options intentionally.
private getEditorGroupFromOptions(options: { groupId?: number; openToSide?: boolean }): PreferredGroup {
if (this.configurationService.getValue<string>('workbench.editor.useModal') !== 'off') {
return MODAL_GROUP;
}
if (options.openToSide) {
return SIDE_GROUP;
}
if (options?.groupId !== undefined) {
return this.editorGroupService.getGroup(options.groupId) ?? this.editorGroupService.activeGroup;
}
aeschli
previously approved these changes
Mar 3, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
justschen
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.
fix #297334