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 {
305
305
return this . input . selectionEnd === this . input . value . length && this . input . selectionStart === this . input . selectionEnd ;
306
306
}
307
307
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
+
308
320
public enable ( ) : void {
309
321
this . input . removeAttribute ( 'disabled' ) ;
310
322
}
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
92
92
}
93
93
}
94
94
95
+ // Store the existing selection if there was one.
96
+ const visibleSelection = visibleQuickAccess ?. picker ?. valueSelection ;
97
+
95
98
// Create a picker for the provider to use with the initial value
96
99
// and adjust the filtering to exclude the prefix from filtering
97
100
const disposables = new DisposableStore ( ) ;
@@ -148,6 +151,11 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
148
151
// on the onDidHide event.
149
152
picker . show ( ) ;
150
153
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
+
151
159
// Pick mode: return with promise
152
160
if ( pick ) {
153
161
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
725
725
return this . ui . keyMods ;
726
726
}
727
727
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 ) {
729
737
this . _valueSelection = valueSelection ;
730
738
this . valueSelectionUpdated = true ;
731
739
this . update ( ) ;
@@ -1154,7 +1162,15 @@ export class InputBox extends QuickInput implements IInputBox {
1154
1162
this . update ( ) ;
1155
1163
}
1156
1164
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 ) {
1158
1174
this . _valueSelection = valueSelection ;
1159
1175
this . valueSelectionUpdated = true ;
1160
1176
this . update ( ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ export class QuickInputBox extends Disposable {
59
59
this . findInput . inputBox . select ( range ) ;
60
60
}
61
61
62
+ getSelection ( ) : IRange | null {
63
+ return this . findInput . inputBox . getSelection ( ) ;
64
+ }
65
+
62
66
isSelectionAtEnd ( ) : boolean {
63
67
return this . findInput . inputBox . isSelectionAtEnd ( ) ;
64
68
}
You can’t perform that action at this time.
0 commit comments