File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
packages/cursorless-vscode/src/ide/vscode Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,12 @@ export function vscodeShowQuickPick(
33
33
}
34
34
35
35
if ( options ?. defaultValue != null ) {
36
- quickPick . activeItems = quickPickItems . filter (
36
+ const activeItem = quickPickItems . find (
37
37
( item ) => item . value === options . defaultValue ,
38
38
) ;
39
+ if ( activeItem != null ) {
40
+ quickPick . activeItems = [ activeItem ] ;
41
+ }
39
42
}
40
43
41
44
if ( options ?. unknownValues ) {
@@ -45,19 +48,17 @@ export function vscodeShowQuickPick(
45
48
: "Add new value '{}' →" ;
46
49
47
50
quickPick . onDidChangeValue ( ( ) => {
48
- quickPick . items = [
49
- ...quickPickItems ,
50
-
51
- // INJECT user values into proposed values
52
- ...( items . includes ( quickPick . value ) || quickPick . value . trim ( ) === ""
53
- ? [ ]
51
+ const value = quickPick . value . trim ( ) ;
52
+ quickPick . items =
53
+ value === "" || items . includes ( value )
54
+ ? quickPickItems
54
55
: [
56
+ ...quickPickItems ,
55
57
{
56
- label : newValueTemplate . replace ( "{}" , quickPick . value ) ,
57
- value : quickPick . value ,
58
+ label : newValueTemplate . replace ( "{}" , value ) ,
59
+ value,
58
60
} ,
59
- ] ) ,
60
- ] ;
61
+ ] ;
61
62
} ) ;
62
63
}
63
64
You can’t perform that action at this time.
0 commit comments