Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset holdMode when losing window focus #203368

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/vs/workbench/services/keybinding/browser/keybindingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {

// for single modifier chord keybindings (e.g. shift shift)
disposables.add(dom.addDisposableListener(window, dom.EventType.KEY_UP, (e: KeyboardEvent) => {
if (this._keybindingHoldMode) {
this._keybindingHoldMode.complete();
this._keybindingHoldMode = null;
}
this._resetKeybindingHoldMode();
this.isComposingGlobalContextKey.set(e.isComposing);
const keyEvent = new StandardKeyboardEvent(e);
const shouldPreventDefault = this._singleModifierDispatch(keyEvent, keyEvent.target);
Expand Down Expand Up @@ -405,10 +402,23 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return undefined;
}
this._keybindingHoldMode = new DeferredPromise<void>();
const focusTracker = dom.trackFocus(dom.getWindow(undefined));
const listener = focusTracker.onDidBlur(() => this._resetKeybindingHoldMode());
this._keybindingHoldMode.p.finally(() => {
listener.dispose();
focusTracker.dispose();
});
this._log(`+ Enabled hold-mode for ${commandId}.`);
return this._keybindingHoldMode.p;
}

private _resetKeybindingHoldMode(): void {
if (this._keybindingHoldMode) {
this._keybindingHoldMode?.complete();
this._keybindingHoldMode = null;
}
}

public override customKeybindingsCount(): number {
return this.userKeybindings.keybindings.length;
}
Expand Down