Skip to content

Commit 07bdf34

Browse files
authored
Problems view - Can't multi-select in table mode (microsoft#151788)
Fix microsoft#150977
1 parent 1d1919a commit 07bdf34

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

src/vs/workbench/contrib/markers/browser/markersTable.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export class MarkersTable extends Disposable implements IProblemsWidget {
375375

376376
getFocus(): (MarkerTableItem | null)[] {
377377
const focus = this.table.getFocus();
378-
return focus.length > 0 ? [this.table.row(focus[0])] : [];
378+
return focus.length > 0 ? [...focus.map(f => this.table.row(f))] : [];
379379
}
380380

381381
getHTMLElement(): HTMLElement {
@@ -388,7 +388,7 @@ export class MarkersTable extends Disposable implements IProblemsWidget {
388388

389389
getSelection(): (MarkerTableItem | null)[] {
390390
const selection = this.table.getSelection();
391-
return selection.length > 0 ? [this.table.row(selection[0])] : [];
391+
return selection.length > 0 ? [...selection.map(i => this.table.row(i))] : [];
392392
}
393393

394394
getVisibleItemCount(): number {
@@ -499,13 +499,15 @@ export class MarkersTable extends Disposable implements IProblemsWidget {
499499
this.table.domNode.ariaLabel = label;
500500
}
501501

502-
setMarkerSelection(marker?: Marker): void {
502+
setMarkerSelection(selection?: Marker[], focus?: Marker[]): void {
503503
if (this.isVisible()) {
504-
if (marker) {
505-
const index = this.findMarkerIndex(marker);
506-
if (index !== -1) {
507-
this.table.setFocus([index]);
508-
this.table.setSelection([index]);
504+
if (selection && selection.length > 0) {
505+
this.table.setSelection(selection.map(m => this.findMarkerIndex(m)));
506+
507+
if (focus && focus.length > 0) {
508+
this.table.setFocus(focus.map(f => this.findMarkerIndex(f)));
509+
} else {
510+
this.table.setFocus([this.findMarkerIndex(selection[0])]);
509511
}
510512
} else if (this.getSelection().length === 0 && this.getVisibleItemCount() > 0) {
511513
this.table.setFocus([0]);

src/vs/workbench/contrib/markers/browser/markersView.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export interface IProblemsWidget {
9090
reset(resourceMarkers: ResourceMarkers[]): void;
9191
revealMarkers(activeResource: ResourceMarkers | null, focus: boolean, lastSelectedRelativeTop: number): void;
9292
setAriaLabel(label: string): void;
93-
setMarkerSelection(marker?: Marker): void;
93+
setMarkerSelection(selection?: Marker[], focus?: Marker[]): void;
9494
toggleVisibility(hide: boolean): void;
9595
update(resourceMarkers: ResourceMarkers[]): void;
9696
updateMarker(marker: Marker): void;
@@ -451,7 +451,7 @@ export class MarkersView extends ViewPane implements IMarkersView {
451451
accessibilityProvider: this.widgetAccessibilityProvider,
452452
horizontalScrolling: false,
453453
identityProvider: this.widgetIdentityProvider,
454-
multipleSelectionSupport: false,
454+
multipleSelectionSupport: true,
455455
selectionNavigation: true
456456
},
457457
);
@@ -599,16 +599,31 @@ export class MarkersView extends ViewPane implements IMarkersView {
599599
}
600600

601601
// Save selection
602-
const selection = this.widget?.getSelection();
602+
const selection = new Set<Marker>();
603+
for (const marker of this.widget.getSelection()) {
604+
if (marker instanceof ResourceMarkers) {
605+
marker.markers.forEach(m => selection.add(m));
606+
} else if (marker instanceof Marker || marker instanceof MarkerTableItem) {
607+
selection.add(marker);
608+
}
609+
}
610+
611+
// Save focus
612+
const focus = new Set<Marker>();
613+
for (const marker of this.widget.getFocus()) {
614+
if (marker instanceof Marker || marker instanceof MarkerTableItem) {
615+
focus.add(marker);
616+
}
617+
}
603618

604619
// Create new widget
605620
this.createWidget(this.widgetContainer);
606621
this.refreshPanel();
607622

608623
// Restore selection
609-
if (selection && selection.length > 0 && (selection[0] instanceof Marker || selection[0] instanceof MarkerTableItem)) {
624+
if (selection.size > 0) {
625+
this.widget.setMarkerSelection(Array.from(selection), Array.from(focus));
610626
this.widget.domFocus();
611-
this.widget.setMarkerSelection(selection[0]);
612627
}
613628
}
614629

@@ -982,14 +997,15 @@ class MarkersTree extends WorkbenchObjectTree<MarkerElement, FilterData> impleme
982997
this.ariaLabel = label;
983998
}
984999

985-
setMarkerSelection(marker: Marker): void {
1000+
setMarkerSelection(selection?: Marker[], focus?: Marker[]): void {
9861001
if (this.isVisible()) {
987-
if (marker) {
988-
const markerNode = this.findMarkerNode(marker);
1002+
if (selection && selection.length > 0) {
1003+
this.setSelection(selection.map(m => this.findMarkerNode(m)));
9891004

990-
if (markerNode) {
991-
this.setFocus([markerNode]);
992-
this.setSelection([markerNode]);
1005+
if (focus && focus.length > 0) {
1006+
this.setFocus(focus.map(f => this.findMarkerNode(f)));
1007+
} else {
1008+
this.setFocus([this.findMarkerNode(selection[0])]);
9931009
}
9941010
} else if (this.getSelection().length === 0) {
9951011
const firstVisibleElement = this.firstVisibleElement;
@@ -1026,7 +1042,7 @@ class MarkersTree extends WorkbenchObjectTree<MarkerElement, FilterData> impleme
10261042
}
10271043
}
10281044

1029-
return undefined;
1045+
return null;
10301046
}
10311047

10321048
private hasSelectedMarkerFor(resource: ResourceMarkers): boolean {

0 commit comments

Comments
 (0)