Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[markers] fix false positive problem tabbar decorators #6132

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions packages/markers/src/browser/problem/problem-tabbar-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
********************************************************************************/

import { inject, injectable, postConstruct } from 'inversify';
import { Diagnostic } from 'vscode-languageserver-types';
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-types';
import { Event, Emitter } from '@theia/core/lib/common/event';
import { Title, Widget } from '@phosphor/widgets';
import { WidgetDecoration } from '@theia/core/lib/browser/widget-decoration';
Expand Down Expand Up @@ -49,9 +49,27 @@ export class ProblemTabBarDecorator implements TabBarDecorator {
if (Navigatable.is(widget)) {
const resourceUri = widget.getResourceUri();
if (resourceUri) {
return this.problemManager.findMarkers({
uri: resourceUri
}).map(marker => this.toDecorator(marker));
// Get the list of problem markers for the given resource URI.
const markers: Marker<Diagnostic>[] = this.problemManager.findMarkers({ uri: resourceUri });
// If no markers are available, return early.
if (markers.length === 0) {
return [];
}
// Store the marker with the highest severity.
let maxSeverity: Marker<Diagnostic> | undefined;
// Iterate over available markers to determine that which has the highest severity.
// Only display a decoration if an error or warning marker is available.
for (const marker of markers) {
// Break early if an error marker is present, since it represents the highest severity.
if (marker.data.severity === DiagnosticSeverity.Error) {
maxSeverity = marker;
break;
} else if (marker.data.severity === DiagnosticSeverity.Warning) {
maxSeverity = marker;
}
}
// Decorate the tabbar with the highest marker severity if available.
return maxSeverity ? [this.toDecorator(maxSeverity)] : [];
vince-fugnitto marked this conversation as resolved.
Show resolved Hide resolved
}
}
return [];
Expand Down