Skip to content

Commit

Permalink
Allow menu bar mnemonics in the terminal (setting)
Browse files Browse the repository at this point in the history
Fixes #91908
  • Loading branch information
Tyriar committed Mar 2, 2020
1 parent 78b5a91 commit 018b3fe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ configurationRegistry.registerConfiguration({
type: 'boolean',
default: true
},
'terminal.integrated.allowMenubarMnemonics': {
markdownDescription: nls.localize('terminal.integrated.allowMenubarMnemonics', "Whether to allow menubar mnemonics (eg. alt+f) to trigger the open the menubar. Note that this will cause all alt keystrokes will skip the shell when true."),
type: 'boolean',
default: false
},
'terminal.integrated.inheritEnv': {
markdownDescription: nls.localize('terminal.integrated.inheritEnv', "Whether new shells should inherit their environment from VS Code. This is not supported on Windows."),
type: 'boolean',
Expand Down
19 changes: 15 additions & 4 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,19 +595,30 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
return false;
}

// Skip processing by xterm.js of keyboard events that resolve to commands described
// within commandsToSkipShell
const standardKeyboardEvent = new StandardKeyboardEvent(event);
const resolveResult = this._keybindingService.softDispatch(standardKeyboardEvent, standardKeyboardEvent.target);

// Respect chords if the allowChords setting is set and it's not Escape. Escape is
// handled specially for Zen Mode's Escape, Escape chord, plus it's important in
// terminals generally
const allowChords = resolveResult?.enterChord && this._configHelper.config.allowChords && event.key !== 'Escape';
if (this._keybindingService.inChordMode || allowChords || resolveResult && this._skipTerminalCommands.some(k => k === resolveResult.commandId)) {
const isValidChord = resolveResult?.enterChord && this._configHelper.config.allowChords && event.key !== 'Escape';
if (this._keybindingService.inChordMode || isValidChord) {
event.preventDefault();
return false;
}

// Skip processing by xterm.js of keyboard events that resolve to commands described
// within commandsToSkipShell
if (resolveResult && this._skipTerminalCommands.some(k => k === resolveResult.commandId)) {
event.preventDefault();
return false;
}

// Skip processing by xterm.js of keyboard events that match menu bar mnemonics
if (this._configHelper.config.allowMenubarMnemonics && event.altKey) {
return false;
}

// If tab focus mode is on, tab is not passed to the terminal
if (TabFocus.getTabFocusMode() && event.keyCode === 9) {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export interface ITerminalConfiguration {
scrollback: number;
commandsToSkipShell: string[];
allowChords: boolean;
allowMenubarMnemonics: boolean;
cwd: string;
confirmOnExit: boolean;
enableBell: boolean;
Expand Down

0 comments on commit 018b3fe

Please sign in to comment.