Skip to content

Commit 14cf2b8

Browse files
committed
Always dispatch to keybinding service when in chord mode in terminal
Fixes microsoft#91238
1 parent 8bb8f21 commit 14cf2b8

5 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/vs/platform/keybinding/common/abstractKeybindingService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
3535
private _currentChordChecker: IntervalTimer;
3636
private _currentChordStatusMessage: IDisposable | null;
3737

38+
public get inChordMode(): boolean {
39+
return !!this._currentChord;
40+
}
41+
3842
constructor(
3943
private _contextKeyService: IContextKeyService,
4044
protected _commandService: ICommandService,

src/vs/platform/keybinding/common/keybinding.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const IKeybindingService = createDecorator<IKeybindingService>('keybindin
5050
export interface IKeybindingService {
5151
_serviceBrand: undefined;
5252

53+
readonly inChordMode: boolean;
54+
5355
onDidUpdateKeybindings: Event<IKeybindingEvent>;
5456

5557
/**

src/vs/platform/keybinding/common/keybindingResolver.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe
1111
import { keys } from 'vs/base/common/map';
1212

1313
export interface IResolveResult {
14+
/** Whether the resolved keybinding is entering a chord */
1415
enterChord: boolean;
16+
/** Whether the resolved keybinding is leaving (and executing) a chord */
17+
leaveChord: boolean;
1518
commandId: string | null;
1619
commandArgs: any;
1720
bubble: boolean;
@@ -285,6 +288,7 @@ export class KeybindingResolver {
285288
if (currentChord === null && result.keypressParts.length > 1 && result.keypressParts[1] !== null) {
286289
return {
287290
enterChord: true,
291+
leaveChord: false,
288292
commandId: null,
289293
commandArgs: null,
290294
bubble: false
@@ -293,6 +297,7 @@ export class KeybindingResolver {
293297

294298
return {
295299
enterChord: false,
300+
leaveChord: result.keypressParts.length > 1,
296301
commandId: result.command,
297302
commandArgs: result.commandArgs,
298303
bubble: result.bubble

src/vs/platform/keybinding/test/common/mockKeybindingService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export class MockContextKeyService implements IContextKeyService {
7171
export class MockKeybindingService implements IKeybindingService {
7272
public _serviceBrand: undefined;
7373

74+
public readonly inChordMode: boolean = false;
75+
7476
public get onDidUpdateKeybindings(): Event<IKeybindingEvent> {
7577
return Event.None;
7678
}

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
602602
// Respect chords if the allowChords setting is set and it's not Escape. Escape is
603603
// handled specially for Zen Mode's Escape, Escape chord, plus it's important in
604604
// terminals generally
605-
const allowChords = resolveResult && resolveResult.enterChord && this._configHelper.config.allowChords && event.key !== 'Escape';
606-
if (allowChords || resolveResult && this._skipTerminalCommands.some(k => k === resolveResult.commandId)) {
605+
const allowChords = resolveResult?.enterChord && this._configHelper.config.allowChords && event.key !== 'Escape';
606+
if (this._keybindingService.inChordMode || allowChords || resolveResult && this._skipTerminalCommands.some(k => k === resolveResult.commandId)) {
607607
event.preventDefault();
608608
return false;
609609
}

0 commit comments

Comments
 (0)