diff --git a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts index 1f3b578f1e3e3946f6e6e92c8e7adffb701a8a07..a1192053e0571dbf33ede028d710c6be9ce105bb 100644 --- a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts +++ b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts @@ -152,6 +152,7 @@ export class QuickOpenWidget implements IModelProvider { DOM.addDisposableListener(this.inputBox.inputElement, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => { const keyboardEvent: StandardKeyboardEvent = new StandardKeyboardEvent(e); + const shouldOpenInBackground = this.shouldOpenInBackground(keyboardEvent); // Do not handle Tab: It is used to navigate between elements without mouse if (keyboardEvent.keyCode === KeyCode.Tab) { @@ -165,13 +166,13 @@ export class QuickOpenWidget implements IModelProvider { this.navigateInTree(keyboardEvent.keyCode, keyboardEvent.shiftKey); } - // Select element on Enter - else if (keyboardEvent.keyCode === KeyCode.Enter || keyboardEvent.keyCode === KeyCode.RightArrow) { + // Select element on Enter or on Arrow-Right if we are at the end of the input + else if (keyboardEvent.keyCode === KeyCode.Enter || shouldOpenInBackground) { DOM.EventHelper.stop(e, true); const focus = this.tree.getFocus(); if (focus) { - this.elementSelected(focus, e, keyboardEvent.keyCode === KeyCode.RightArrow ? Mode.OPEN_IN_BACKGROUND : Mode.OPEN); + this.elementSelected(focus, e, shouldOpenInBackground ? Mode.OPEN_IN_BACKGROUND : Mode.OPEN); } } @@ -304,6 +305,18 @@ export class QuickOpenWidget implements IModelProvider { return this.builder.getHTMLElement(); } + private shouldOpenInBackground(e: StandardKeyboardEvent): boolean { + if (e.keyCode !== KeyCode.RightArrow) { + return false; // only for right arrow + } + + if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { + return false; // no modifiers allowed + } + + return this.inputBox.inputElement.selectionStart === this.inputBox.value.length; // only when cursor is at the end of the input field value + } + private onType(): void { const value = this.inputBox.value;