mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
don't merge diagnostics with old data, fixes #11547
This commit is contained in:
@@ -8,6 +8,7 @@ import {localize} from 'vs/nls';
|
||||
import {IThreadService} from 'vs/workbench/services/thread/common/threadService';
|
||||
import {IMarkerData} from 'vs/platform/markers/common/markers';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {compare} from 'vs/base/common/strings';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import * as vscode from 'vscode';
|
||||
import {MainContext, MainThreadDiagnosticsShape, ExtHostDiagnosticsShape} from './extHost.protocol';
|
||||
@@ -72,20 +73,23 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
} else if (Array.isArray(first)) {
|
||||
// update many rows
|
||||
toSync = [];
|
||||
for (let entry of first) {
|
||||
let [uri, diagnostics] = entry;
|
||||
toSync.push(uri);
|
||||
let lastUri: vscode.Uri;
|
||||
for (const entry of first.slice(0).sort(DiagnosticCollection._compareTuplesByUri)) {
|
||||
const [uri, diagnostics] = entry;
|
||||
if (!lastUri || uri.toString() !== lastUri.toString()) {
|
||||
if (lastUri && this._data[lastUri.toString()].length === 0) {
|
||||
delete this._data[lastUri.toString()];
|
||||
}
|
||||
lastUri = uri;
|
||||
toSync.push(uri);
|
||||
this._data[uri.toString()] = [];
|
||||
}
|
||||
|
||||
if (!diagnostics) {
|
||||
// [Uri, undefined] means clear this
|
||||
delete this._data[uri.toString()];
|
||||
this._data[uri.toString()].length = 0;
|
||||
} else {
|
||||
// set or merge diagnostics
|
||||
let existing = this._data[uri.toString()];
|
||||
if (existing) {
|
||||
existing.push(...diagnostics);
|
||||
} else {
|
||||
this._data[uri.toString()] = diagnostics;
|
||||
}
|
||||
this._data[uri.toString()].push(...diagnostics);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,6 +200,10 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
default: return Severity.Error;
|
||||
}
|
||||
}
|
||||
|
||||
private static _compareTuplesByUri(a: [vscode.Uri, vscode.Diagnostic[]], b: [vscode.Uri, vscode.Diagnostic[]]): number {
|
||||
return compare(a[0].toString(), b[0].toString());
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostDiagnostics extends ExtHostDiagnosticsShape {
|
||||
|
||||
Reference in New Issue
Block a user