mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fix #63019
This commit is contained in:
parent
c507f6347b
commit
ecaee2f53e
|
@ -20,10 +20,15 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||
import { ToggleMarkersPanelAction, ShowProblemsPanelAction } from 'vs/workbench/parts/markers/electron-browser/markersPanelActions';
|
||||
import Constants from 'vs/workbench/parts/markers/electron-browser/constants';
|
||||
import Messages from 'vs/workbench/parts/markers/electron-browser/messages';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IMarkersWorkbenchService, MarkersWorkbenchService, ActivityUpdater } from 'vs/workbench/parts/markers/electron-browser/markers';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
import './markers';
|
||||
import './markersFileDecorations';
|
||||
|
||||
registerSingleton(IMarkersWorkbenchService, MarkersWorkbenchService, false);
|
||||
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: Constants.MARKER_OPEN_SIDE_ACTION_ID,
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
|
@ -74,6 +79,10 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescri
|
|||
ToggleMarkersPanelAction.ID
|
||||
));
|
||||
|
||||
// workbench
|
||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
workbenchRegistry.registerWorkbenchContribution(ActivityUpdater, LifecyclePhase.Running);
|
||||
|
||||
// actions
|
||||
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMarkersPanelAction, ToggleMarkersPanelAction.ID, ToggleMarkersPanelAction.LABEL, {
|
||||
|
|
|
@ -11,8 +11,8 @@ import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/co
|
|||
import { localize } from 'vs/nls';
|
||||
import Constants from './constants';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { groupBy } from 'vs/base/common/arrays';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
|
||||
export const IMarkersWorkbenchService = createDecorator<IMarkersWorkbenchService>('markersWorkbenchService');
|
||||
|
||||
|
@ -33,7 +33,6 @@ export class MarkersWorkbenchService extends Disposable implements IMarkersWorkb
|
|||
|
||||
constructor(
|
||||
@IMarkerService private markerService: IMarkerService,
|
||||
@IActivityService private activityService: IActivityService,
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
super();
|
||||
|
@ -50,19 +49,28 @@ export class MarkersWorkbenchService extends Disposable implements IMarkersWorkb
|
|||
for (const resource of resources) {
|
||||
this.markersModel.setResourceMarkers(resource, this.readMarkers(resource));
|
||||
}
|
||||
|
||||
this.refreshBadge();
|
||||
}
|
||||
|
||||
private readMarkers(resource?: URI): IMarker[] {
|
||||
return this.markerService.read({ resource, severities: MarkerSeverity.Error | MarkerSeverity.Warning | MarkerSeverity.Info });
|
||||
}
|
||||
|
||||
private refreshBadge(): void {
|
||||
const total = this.markersModel.resourceMarkers.reduce((r, rm) => r + rm.markers.length, 0);
|
||||
}
|
||||
|
||||
export class ActivityUpdater extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IActivityService private activityService: IActivityService,
|
||||
@IMarkersWorkbenchService private markersWorkbenchService: IMarkersWorkbenchService
|
||||
) {
|
||||
super();
|
||||
this._register(this.markersWorkbenchService.markersModel.onDidChange(() => this.updateBadge()));
|
||||
this.updateBadge();
|
||||
}
|
||||
|
||||
private updateBadge(): void {
|
||||
const total = this.markersWorkbenchService.markersModel.resourceMarkers.reduce((r, rm) => r + rm.markers.length, 0);
|
||||
const message = localize('totalProblems', 'Total {0} Problems', total);
|
||||
this.activityService.showActivity(Constants.MARKERS_PANEL_ID, new NumberBadge(total, () => message));
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IMarkersWorkbenchService, MarkersWorkbenchService, true);
|
||||
}
|
Loading…
Reference in a new issue