From 84560eb3a7b71aeef4ffa651f4636962469c0f38 Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Wed, 18 Dec 2019 09:37:12 -0500 Subject: [PATCH] Add problems statusbar tooltip - adds a tooltip to the problems statusbar when hovering over the item. - displays `No Problems` when no problems are present. - displays the count and type of a problem for each problem stat property when problems are present. Signed-off-by: Vincent Fugnitto --- .../browser/problem/problem-contribution.ts | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/markers/src/browser/problem/problem-contribution.ts b/packages/markers/src/browser/problem/problem-contribution.ts index 3ff29d52dddb3..6a31cf39ad433 100644 --- a/packages/markers/src/browser/problem/problem-contribution.ts +++ b/packages/markers/src/browser/problem/problem-contribution.ts @@ -87,10 +87,38 @@ export class ProblemContribution extends AbstractViewContribution : `$(times-circle) ${problemStat.errors} $(exclamation-triangle) ${problemStat.warnings} $(info-circle) ${problemStat.infos}`, alignment: StatusBarAlignment.LEFT, priority: 10, - command: this.toggleCommand ? this.toggleCommand.id : undefined + command: this.toggleCommand ? this.toggleCommand.id : undefined, + tooltip: this.getStatusBarTooltip(problemStat) }); } + /** + * Get the tooltip to be displayed when hovering over the problem statusbar item. + * - Displays `No Problems` when no problems are present. + * - Displays a human-readable label which describes for each type of problem stat properties, + * their overall count and type when any one of these properties has a positive count. + * @param stat the problem stat describing the number of `errors`, `warnings` and `infos`. + * + * @return the tooltip to be displayed in the statusbar. + */ + protected getStatusBarTooltip(stat: ProblemStat): string { + if (stat.errors <= 0 && stat.warnings <= 0 && stat.infos <= 0) { + return 'No Problems'; + } + const tooltip: string[] = []; + if (stat.errors > 0) { + tooltip.push(`${stat.errors} Errors`); + } + if (stat.warnings > 0) { + tooltip.push(`${stat.warnings} Warnings`); + } + if (stat.infos > 0) { + tooltip.push(`${stat.infos} Infos`); + } + return tooltip.join(', '); + + } + registerCommands(commands: CommandRegistry): void { super.registerCommands(commands); commands.registerCommand(ProblemsCommands.COLLAPSE_ALL, {