mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
Add arrays.empty
This helps with `a === b` checks in arrays.equals
This commit is contained in:
@@ -18,12 +18,12 @@ function diagnosticsEquals(a: vscode.Diagnostic, b: vscode.Diagnostic): boolean
|
||||
&& a.severity === b.severity
|
||||
&& a.source === b.source
|
||||
&& a.range.isEqual(b.range)
|
||||
&& arrays.equals(a.relatedInformation || [], b.relatedInformation || [], (a, b) => {
|
||||
&& arrays.equals(a.relatedInformation || arrays.empty, b.relatedInformation || arrays.empty, (a, b) => {
|
||||
return a.message === b.message
|
||||
&& a.location.range.isEqual(b.location.range)
|
||||
&& a.location.uri.fsPath === b.location.uri.fsPath;
|
||||
})
|
||||
&& arrays.equals(a.tags || [], b.tags || []);
|
||||
&& arrays.equals(a.tags || arrays.empty, b.tags || arrays.empty);
|
||||
}
|
||||
|
||||
export const enum DiagnosticKind {
|
||||
@@ -51,7 +51,7 @@ class FileDiagnostics {
|
||||
}
|
||||
|
||||
const existing = this._diagnostics.get(kind);
|
||||
if (arrays.equals(existing || [], diagnostics, diagnosticsEquals)) {
|
||||
if (arrays.equals(existing || arrays.empty, diagnostics, diagnosticsEquals)) {
|
||||
// No need to update
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const empty = Object.freeze([]);
|
||||
|
||||
export function equals<T>(
|
||||
a: ReadonlyArray<T>,
|
||||
b: ReadonlyArray<T>,
|
||||
|
||||
Reference in New Issue
Block a user