Skip to content

Commit

Permalink
MarkersModel: bulk update/refresh of resources
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Sep 20, 2016
1 parent 2612a71 commit 2f76c44
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/vs/workbench/parts/markers/browser/markersPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,20 @@ export class MarkersPanel extends Panel {
}

private updateResources(resources: URI[]) {
resources.forEach((resource) => {
let markers = this.markerService.read({ resource: resource }).slice(0);
this.markersModel.update(resource, markers);
const bulkUpdater = this.markersModel.getBulkUpdater();
for (const resource of resources) {
bulkUpdater.add(resource, this.markerService.read({ resource }));
}
bulkUpdater.done();
for (const resource of resources) {
if (!this.markersModel.hasResource(resource)) {
this.autoExpanded.unset(resource.toString());
}
});
}
}

private render(): void {
let allMarkers = this.markerService.read().slice(0);
let allMarkers = this.markerService.read();
this.markersModel.update(allMarkers);
this.tree.setInput(this.markersModel).then(this.autoExpand.bind(this));
dom.toggleClass(this.treeContainer, 'hidden', !this.markersModel.hasFilteredResources());
Expand Down
16 changes: 16 additions & 0 deletions src/vs/workbench/parts/markers/common/markersModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import { IMarker, MarkerStatistics } from 'vs/platform/markers/common/markers';
import {IFilter, IMatch, or, matchesContiguousSubString, matchesPrefix, matchesFuzzy} from 'vs/base/common/filters';
import Messages from 'vs/workbench/parts/markers/common/messages';

export interface BulkUpdater {
add(resource: URI, markers: IMarker[]);
done();
}

export class Resource {

private _name: string = null;
Expand Down Expand Up @@ -142,6 +147,17 @@ export class MarkersModel {
return this._nonFilteredResources;
}

public getBulkUpdater(): BulkUpdater {
return {
add: (resourceUri: URI, markers: IMarker[]) => {
this.updateResource(resourceUri, markers);
},
done: () => {
this.refresh();
}
};
}

public update(filterOptions: FilterOptions);
public update(resourceUri: URI, markers: IMarker[]);
public update(markers: IMarker[]);
Expand Down

1 comment on commit 2f76c44

@sandy081
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #11976

Please sign in to comment.