Use array.equals

This commit is contained in:
Matt Bierner 2020-09-16 01:36:33 -07:00
parent 7bf5773eb2
commit 240afbde58

View file

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { equals } from '../util/arrays';
export class MarkdownPreviewConfiguration { export class MarkdownPreviewConfiguration {
public static getForResource(resource: vscode.Uri) { public static getForResource(resource: vscode.Uri) {
@ -21,7 +22,7 @@ export class MarkdownPreviewConfiguration {
public readonly lineHeight: number; public readonly lineHeight: number;
public readonly fontSize: number; public readonly fontSize: number;
public readonly fontFamily: string | undefined; public readonly fontFamily: string | undefined;
public readonly styles: string[]; public readonly styles: readonly string[];
private constructor(resource: vscode.Uri) { private constructor(resource: vscode.Uri) {
const editorConfig = vscode.workspace.getConfiguration('editor', resource); const editorConfig = vscode.workspace.getConfiguration('editor', resource);
@ -49,7 +50,7 @@ export class MarkdownPreviewConfiguration {
} }
public isEqualTo(otherConfig: MarkdownPreviewConfiguration) { public isEqualTo(otherConfig: MarkdownPreviewConfiguration) {
for (let key in this) { for (const key in this) {
if (this.hasOwnProperty(key) && key !== 'styles') { if (this.hasOwnProperty(key) && key !== 'styles') {
if (this[key] !== otherConfig[key]) { if (this[key] !== otherConfig[key]) {
return false; return false;
@ -57,17 +58,7 @@ export class MarkdownPreviewConfiguration {
} }
} }
// Check styles return equals(this.styles, otherConfig.styles);
if (this.styles.length !== otherConfig.styles.length) {
return false;
}
for (let i = 0; i < this.styles.length; ++i) {
if (this.styles[i] !== otherConfig.styles[i]) {
return false;
}
}
return true;
} }
[key: string]: any; [key: string]: any;