Skip to content

Commit 07a9742

Browse files
authored
Don't contribute to statsBar when setting is off (microsoft#199592)
* various end game fixes * added missing space * better bool logic * don't contribute problems when setting is off * added problems visibility toggle to switch on * fix merge conflic * fix from PR comments, removing register
1 parent a6c7270 commit 07a9742

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ registerAction2(class extends Action2 {
559559
class MarkersStatusBarContributions extends Disposable implements IWorkbenchContribution {
560560

561561
private markersStatusItem: IStatusbarEntryAccessor;
562-
private markersStatusItemOff: IStatusbarEntryAccessor;
562+
private markersStatusItemOff: IStatusbarEntryAccessor | undefined;
563563

564564
constructor(
565565
@IMarkerService private readonly markerService: IMarkerService,
@@ -568,15 +568,33 @@ class MarkersStatusBarContributions extends Disposable implements IWorkbenchCont
568568
) {
569569
super();
570570
this.markersStatusItem = this._register(this.statusbarService.addEntry(this.getMarkersItem(), 'status.problems', StatusbarAlignment.LEFT, 50 /* Medium Priority */));
571-
this.markersStatusItemOff = this._register(this.statusbarService.addEntry(this.getMarkersItemTurnedOff(), 'status.problemsVisibility', StatusbarAlignment.LEFT, 49));
571+
572+
const addStatusBarEntry = () => {
573+
this.markersStatusItemOff = this.statusbarService.addEntry(this.getMarkersItemTurnedOff(), 'status.problemsVisibility', StatusbarAlignment.LEFT, 49);
574+
};
575+
576+
// Add the status bar entry if the problems is not visible
577+
let config = this.configurationService.getValue('problems.visibility');
578+
if (!config) {
579+
addStatusBarEntry();
580+
}
581+
572582
this._register(this.markerService.onMarkerChanged(() => {
573583
this.markersStatusItem.update(this.getMarkersItem());
574-
this.markersStatusItemOff.update(this.getMarkersItemTurnedOff());
575584
}));
585+
576586
this._register(this.configurationService.onDidChangeConfiguration(e => {
577587
if (e.affectsConfiguration('problems.visibility')) {
578588
this.markersStatusItem.update(this.getMarkersItem());
579-
this.markersStatusItemOff.update(this.getMarkersItemTurnedOff());
589+
590+
// Update based on what setting was changed to.
591+
config = this.configurationService.getValue('problems.visibility');
592+
if (!config && !this.markersStatusItemOff) {
593+
addStatusBarEntry();
594+
} else if (config && this.markersStatusItemOff) {
595+
this.markersStatusItemOff.dispose();
596+
this.markersStatusItemOff = undefined;
597+
}
580598
}
581599
}));
582600
}
@@ -594,12 +612,11 @@ class MarkersStatusBarContributions extends Disposable implements IWorkbenchCont
594612
}
595613

596614
private getMarkersItemTurnedOff(): IStatusbarEntry {
597-
const config = this.configurationService.getValue('problems.visibility');
598-
this.statusbarService.updateEntryVisibility('status.problemsVisibility', !config);
599-
615+
// Update to true, config checked before `getMarkersItemTurnedOff` is called.
616+
this.statusbarService.updateEntryVisibility('status.problemsVisibility', true);
600617
const openSettingsCommand = 'workbench.action.openSettings';
601618
const configureSettingsLabel = '@id:problems.visibility';
602-
const tooltip = !config ? localize('problemsOff', "Problems have been turned off.") : '';
619+
const tooltip = localize('status.problemsVisibilityOff', "Problems are turned off. Click to open settings.");
603620
return {
604621
name: localize('status.problemsVisibility', "Problems Visibility"),
605622
text: '$(whole-word)',

0 commit comments

Comments
 (0)