File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/vs/base/parts/quickinput/browser Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -818,9 +818,15 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
818
818
} ) ) ;
819
819
this . visibleDisposables . add ( this . ui . onDidAccept ( ( ) => {
820
820
if ( this . canSelectMany ) {
821
- this . _selectedItems = this . ui . list . getCheckedElements ( ) as T [ ] ;
822
- this . onDidChangeSelectionEmitter . fire ( this . selectedItems ) ;
821
+ // if there are no checked elements, it means that an onDidChangeSelection never fired to overwrite
822
+ // `_selectedItems`. In that case, we should emit one with an empty array to ensure that
823
+ // `.selectedItems` is up to date.
824
+ if ( ! this . ui . list . getCheckedElements ( ) . length ) {
825
+ this . _selectedItems = [ ] ;
826
+ this . onDidChangeSelectionEmitter . fire ( this . selectedItems ) ;
827
+ }
823
828
} else if ( this . activeItems [ 0 ] ) {
829
+ // For single-select, we set `selectedItems` to the item that was accepted.
824
830
this . _selectedItems = [ this . activeItems [ 0 ] ] ;
825
831
this . onDidChangeSelectionEmitter . fire ( this . selectedItems ) ;
826
832
}
You can’t perform that action at this time.
0 commit comments