Skip to content

Commit cd120ba

Browse files
committed
context keys introduce "listMultiSelection"
fixes microsoft#43319
1 parent 73e104d commit cd120ba

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/vs/platform/list/browser/listService.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const RawWorkbenchListFocusContextKey = new RawContextKey<boolean>('listFocus',
8383
export const WorkbenchListSupportsMultiSelectContextKey = new RawContextKey<boolean>('listSupportsMultiselect', true);
8484
export const WorkbenchListFocusContextKey = ContextKeyExpr.and(RawWorkbenchListFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey));
8585
export const WorkbenchListDoubleSelection = new RawContextKey<boolean>('listDoubleSelection', false);
86+
export const WorkbenchListMultiSelection = new RawContextKey<boolean>('listMultiSelection', false);
8687

8788
export type Widget = List<any> | PagedList<any> | ITree;
8889

@@ -166,6 +167,7 @@ export class WorkbenchList<T> extends List<T> {
166167
readonly contextKeyService: IContextKeyService;
167168

168169
private listDoubleSelection: IContextKey<boolean>;
170+
private listMultiSelection: IContextKey<boolean>;
169171

170172
private _useAltAsMultipleSelectionModifier: boolean;
171173

@@ -183,14 +185,19 @@ export class WorkbenchList<T> extends List<T> {
183185

184186
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
185187
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
188+
this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
186189

187190
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
188191

189192
this.disposables.push(combinedDisposable([
190193
this.contextKeyService,
191194
(listService as ListService).register(this),
192195
attachListStyler(this, themeService),
193-
this.onSelectionChange(() => this.listDoubleSelection.set(this.getSelection().length === 2))
196+
this.onSelectionChange(() => {
197+
const selection = this.getSelection();
198+
this.listMultiSelection.set(selection.length > 1);
199+
this.listDoubleSelection.set(selection.length === 2);
200+
})
194201
]));
195202

196203
this.registerListeners();
@@ -266,6 +273,7 @@ export class WorkbenchTree extends Tree {
266273
protected disposables: IDisposable[] = [];
267274

268275
private listDoubleSelection: IContextKey<boolean>;
276+
private listMultiSelection: IContextKey<boolean>;
269277

270278
private _openOnSingleClick: boolean;
271279
private _useAltAsMultipleSelectionModifier: boolean;
@@ -284,6 +292,7 @@ export class WorkbenchTree extends Tree {
284292

285293
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
286294
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
295+
this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
287296

288297
this._openOnSingleClick = useSingleClickToOpen(configurationService);
289298
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
@@ -309,6 +318,7 @@ export class WorkbenchTree extends Tree {
309318
this.disposables.push(this.onDidChangeSelection(() => {
310319
const selection = this.getSelection();
311320
this.listDoubleSelection.set(selection && selection.length === 2);
321+
this.listMultiSelection.set(selection && selection.length > 1);
312322
}));
313323

314324
this.disposables.push(this.configurationService.onDidChangeConfiguration(e => {

0 commit comments

Comments
 (0)