From 348e88dc0099fcedf9578013692ce6ca761f3501 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 7 Feb 2024 10:06:45 -0800 Subject: [PATCH] Revert "Stop the cursor from jumping when changing prefix in QuickAccess (#198821)" (#204638) This reverts commit 3154b5f948de18462d34394aef216e585e25e7ba. --- src/vs/base/browser/ui/inputbox/inputBox.ts | 12 ----------- .../quickinput/browser/quickAccess.ts | 8 -------- .../platform/quickinput/browser/quickInput.ts | 20 ++----------------- .../quickinput/browser/quickInputBox.ts | 4 ---- 4 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index 0a79ae4f8138b..e4c89dd3affb6 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -305,18 +305,6 @@ export class InputBox extends Widget { return this.input.selectionEnd === this.input.value.length && this.input.selectionStart === this.input.selectionEnd; } - public getSelection(): IRange | null { - const selectionStart = this.input.selectionStart; - if (selectionStart === null) { - return null; - } - const selectionEnd = this.input.selectionEnd ?? selectionStart; - return { - start: selectionStart, - end: selectionEnd, - }; - } - public enable(): void { this.input.removeAttribute('disabled'); } diff --git a/src/vs/platform/quickinput/browser/quickAccess.ts b/src/vs/platform/quickinput/browser/quickAccess.ts index 7b4e601436fa3..cb35e451aa151 100644 --- a/src/vs/platform/quickinput/browser/quickAccess.ts +++ b/src/vs/platform/quickinput/browser/quickAccess.ts @@ -92,9 +92,6 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon } } - // Store the existing selection if there was one. - const visibleSelection = visibleQuickAccess?.picker?.valueSelection; - // Create a picker for the provider to use with the initial value // and adjust the filtering to exclude the prefix from filtering const disposables = new DisposableStore(); @@ -151,11 +148,6 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon // on the onDidHide event. picker.show(); - // If the previous picker had a selection, we should set that in the new picker. - if (visibleSelection) { - picker.valueSelection = visibleSelection; - } - // Pick mode: return with promise if (pick) { return pickPromise?.p; diff --git a/src/vs/platform/quickinput/browser/quickInput.ts b/src/vs/platform/quickinput/browser/quickInput.ts index ed28f8c0c1f94..16b52782c26d3 100644 --- a/src/vs/platform/quickinput/browser/quickInput.ts +++ b/src/vs/platform/quickinput/browser/quickInput.ts @@ -725,15 +725,7 @@ export class QuickPick extends QuickInput implements I return this.ui.keyMods; } - get valueSelection() { - const selection = this.ui.inputBox.getSelection(); - if (!selection) { - return undefined; - } - return [selection.start, selection.end]; - } - - set valueSelection(valueSelection: Readonly<[number, number]> | undefined) { + set valueSelection(valueSelection: Readonly<[number, number]>) { this._valueSelection = valueSelection; this.valueSelectionUpdated = true; this.update(); @@ -1162,15 +1154,7 @@ export class InputBox extends QuickInput implements IInputBox { this.update(); } - get valueSelection() { - const selection = this.ui.inputBox.getSelection(); - if (!selection) { - return undefined; - } - return [selection.start, selection.end]; - } - - set valueSelection(valueSelection: Readonly<[number, number]> | undefined) { + set valueSelection(valueSelection: Readonly<[number, number]>) { this._valueSelection = valueSelection; this.valueSelectionUpdated = true; this.update(); diff --git a/src/vs/platform/quickinput/browser/quickInputBox.ts b/src/vs/platform/quickinput/browser/quickInputBox.ts index 9ee1440a91a63..b3c6694387c85 100644 --- a/src/vs/platform/quickinput/browser/quickInputBox.ts +++ b/src/vs/platform/quickinput/browser/quickInputBox.ts @@ -59,10 +59,6 @@ export class QuickInputBox extends Disposable { this.findInput.inputBox.select(range); } - getSelection(): IRange | null { - return this.findInput.inputBox.getSelection(); - } - isSelectionAtEnd(): boolean { return this.findInput.inputBox.isSelectionAtEnd(); }