Skip to content

Commit c524486

Browse files
authored
testing: fix alternate actions being inappropriately sticky (microsoft#227002)
* testing: fix alternate actions being inappropriately sticky We should listen on the window, not just the editor, for alt key events. * fix compile
1 parent f342519 commit c524486

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/vs/workbench/contrib/testing/browser/testingDecorations.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as dom from 'vs/base/browser/dom';
7+
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
78
import { Action, IAction, Separator, SubmenuAction } from 'vs/base/common/actions';
89
import { equals } from 'vs/base/common/arrays';
910
import { RunOnceScheduler } from 'vs/base/common/async';
@@ -456,11 +457,24 @@ export class TestingDecorations extends Disposable implements IEditorContributio
456457
decorations.syncDecorations(this._currentUri);
457458
}
458459
}));
459-
this._register(this.editor.onKeyDown(e => {
460-
if (e.keyCode === KeyCode.Alt && this._currentUri) {
461-
decorations.updateDecorationsAlternateAction(this._currentUri!, true);
460+
461+
const win = dom.getWindow(editor.getDomNode());
462+
this._register(dom.addDisposableListener(win, 'keydown', e => {
463+
if (new StandardKeyboardEvent(e).keyCode === KeyCode.Alt && this._currentUri) {
464+
decorations.updateDecorationsAlternateAction(this._currentUri, true);
465+
}
466+
}));
467+
this._register(dom.addDisposableListener(win, 'keyup', e => {
468+
if (new StandardKeyboardEvent(e).keyCode === KeyCode.Alt && this._currentUri) {
469+
decorations.updateDecorationsAlternateAction(this._currentUri, false);
462470
}
463471
}));
472+
this._register(dom.addDisposableListener(win, 'blur', () => {
473+
if (this._currentUri) {
474+
decorations.updateDecorationsAlternateAction(this._currentUri, false);
475+
}
476+
}));
477+
464478
this._register(this.editor.onKeyUp(e => {
465479
if (e.keyCode === KeyCode.Alt && this._currentUri) {
466480
decorations.updateDecorationsAlternateAction(this._currentUri!, false);

0 commit comments

Comments
 (0)