Skip to content

Commit ec3c083

Browse files
authored
Merge pull request microsoft#45593 from rsalvador/counters
Make problem counters consistent, fixes microsoft#45592
2 parents b64faa9 + 205a503 commit ec3c083

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem {
137137
const info = document.createElement('div');
138138
const building = document.createElement('div');
139139

140+
const errorTitle = n => nls.localize('totalErrors', "{0} Errors", n);
141+
const warningTitle = n => nls.localize('totalWarnings', "{0} Warnings", n);
142+
const infoTitle = n => nls.localize('totalInfos', "{0} Infos", n);
143+
140144
Dom.addClass(element, 'task-statusbar-item');
141145

142146
Dom.addClass(label, 'task-statusbar-item-label');
143147
element.appendChild(label);
144-
element.title = nls.localize('problems', "Problems");
145148

146149
Dom.addClass(errorIcon, 'task-statusbar-item-label-error');
147150
Dom.addClass(errorIcon, 'mask-icon');
@@ -150,6 +153,7 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem {
150153

151154
Dom.addClass(error, 'task-statusbar-item-label-counter');
152155
error.innerHTML = '0';
156+
error.title = errorIcon.title = errorTitle(0);
153157
label.appendChild(error);
154158

155159
Dom.addClass(warningIcon, 'task-statusbar-item-label-warning');
@@ -159,6 +163,7 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem {
159163

160164
Dom.addClass(warning, 'task-statusbar-item-label-counter');
161165
warning.innerHTML = '0';
166+
warning.title = warningIcon.title = warningTitle(0);
162167
label.appendChild(warning);
163168

164169
Dom.addClass(infoIcon, 'task-statusbar-item-label-info');
@@ -186,26 +191,24 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem {
186191
}
187192
}));
188193

189-
let updateStatus = (element: HTMLDivElement, icon: HTMLDivElement, stats: number): boolean => {
190-
if (stats > 0) {
191-
element.innerHTML = stats.toString();
192-
$(element).show();
193-
$(icon).show();
194-
return true;
194+
const manyProblems = nls.localize('manyProblems', "10K+");
195+
const packNumber = n => n > 9999 ? manyProblems : n > 999 ? n.toString().charAt(0) + 'K' : n.toString();
196+
let updateLabel = (stats: MarkerStatistics) => {
197+
error.innerHTML = packNumber(stats.errors);
198+
error.title = errorIcon.title = errorTitle(stats.errors);
199+
warning.innerHTML = packNumber(stats.warnings);
200+
warning.title = warningIcon.title = warningTitle(stats.warnings);
201+
if (stats.infos > 0) {
202+
info.innerHTML = packNumber(stats.infos);
203+
info.title = infoIcon.title = infoTitle(stats.infos);
204+
$(info).show();
205+
$(infoIcon).show();
195206
} else {
196-
$(element).hide();
197-
$(icon).hide();
198-
return false;
207+
$(info).hide();
208+
$(infoIcon).hide();
199209
}
200210
};
201211

202-
let manyMarkers = nls.localize('manyMarkers', "99+");
203-
let updateLabel = (stats: MarkerStatistics) => {
204-
error.innerHTML = stats.errors < 100 ? stats.errors.toString() : manyMarkers;
205-
warning.innerHTML = stats.warnings < 100 ? stats.warnings.toString() : manyMarkers;
206-
updateStatus(info, infoIcon, stats.infos);
207-
};
208-
209212
this.markerService.onMarkerChanged((changedResources) => {
210213
updateLabel(this.markerService.getStatistics());
211214
});

0 commit comments

Comments
 (0)