File tree Expand file tree Collapse file tree 4 files changed +42
-2
lines changed
platform/quickinput/browser Expand file tree Collapse file tree 4 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,18 @@ export class InputBox extends Widget {
305305 return this . input . selectionEnd === this . input . value . length && this . input . selectionStart === this . input . selectionEnd ;
306306 }
307307
308+ public getSelection ( ) : IRange | null {
309+ const selectionStart = this . input . selectionStart ;
310+ if ( selectionStart === null ) {
311+ return null ;
312+ }
313+ const selectionEnd = this . input . selectionEnd ?? selectionStart ;
314+ return {
315+ start : selectionStart ,
316+ end : selectionEnd ,
317+ } ;
318+ }
319+
308320 public enable ( ) : void {
309321 this . input . removeAttribute ( 'disabled' ) ;
310322 }
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
9292 }
9393 }
9494
95+ // Store the existing selection if there was one.
96+ const visibleSelection = visibleQuickAccess ?. picker ?. valueSelection ;
97+
9598 // Create a picker for the provider to use with the initial value
9699 // and adjust the filtering to exclude the prefix from filtering
97100 const disposables = new DisposableStore ( ) ;
@@ -148,6 +151,11 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
148151 // on the onDidHide event.
149152 picker . show ( ) ;
150153
154+ // If the previous picker had a selection, we should set that in the new picker.
155+ if ( visibleSelection ) {
156+ picker . valueSelection = visibleSelection ;
157+ }
158+
151159 // Pick mode: return with promise
152160 if ( pick ) {
153161 return pickPromise ?. p ;
Original file line number Diff line number Diff line change @@ -725,7 +725,15 @@ export class QuickPick<T extends IQuickPickItem> extends QuickInput implements I
725725 return this . ui . keyMods ;
726726 }
727727
728- set valueSelection ( valueSelection : Readonly < [ number , number ] > ) {
728+ get valueSelection ( ) {
729+ const selection = this . ui . inputBox . getSelection ( ) ;
730+ if ( ! selection ) {
731+ return undefined ;
732+ }
733+ return [ selection . start , selection . end ] ;
734+ }
735+
736+ set valueSelection ( valueSelection : Readonly < [ number , number ] > | undefined ) {
729737 this . _valueSelection = valueSelection ;
730738 this . valueSelectionUpdated = true ;
731739 this . update ( ) ;
@@ -1154,7 +1162,15 @@ export class InputBox extends QuickInput implements IInputBox {
11541162 this . update ( ) ;
11551163 }
11561164
1157- set valueSelection ( valueSelection : Readonly < [ number , number ] > ) {
1165+ get valueSelection ( ) {
1166+ const selection = this . ui . inputBox . getSelection ( ) ;
1167+ if ( ! selection ) {
1168+ return undefined ;
1169+ }
1170+ return [ selection . start , selection . end ] ;
1171+ }
1172+
1173+ set valueSelection ( valueSelection : Readonly < [ number , number ] > | undefined ) {
11581174 this . _valueSelection = valueSelection ;
11591175 this . valueSelectionUpdated = true ;
11601176 this . update ( ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ export class QuickInputBox extends Disposable {
5959 this . findInput . inputBox . select ( range ) ;
6060 }
6161
62+ getSelection ( ) : IRange | null {
63+ return this . findInput . inputBox . getSelection ( ) ;
64+ }
65+
6266 isSelectionAtEnd ( ) : boolean {
6367 return this . findInput . inputBox . isSelectionAtEnd ( ) ;
6468 }
You can’t perform that action at this time.
0 commit comments