From 23efb2fbb003092765d65909314deeb01be63186 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 14 Sep 2018 12:34:45 +0200 Subject: [PATCH] fixes #25281 --- src/vs/workbench/api/node/extHostSCM.ts | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/vs/workbench/api/node/extHostSCM.ts b/src/vs/workbench/api/node/extHostSCM.ts index f1996d5ea4b..8c2a8b19534 100644 --- a/src/vs/workbench/api/node/extHostSCM.ts +++ b/src/vs/workbench/api/node/extHostSCM.ts @@ -111,6 +111,37 @@ function compareResourceStates(a: vscode.SourceControlResourceState, b: vscode.S return result; } +function compareArgs(a: any[], b: any[]): boolean { + for (let i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { + return false; + } + } + + return true; +} + +function commandEquals(a: vscode.Command, b: vscode.Command): boolean { + return a.command === b.command + && a.title === b.title + && a.tooltip === b.tooltip + && (a.arguments && b.arguments ? compareArgs(a.arguments, b.arguments) : a.arguments === b.arguments); +} + +function commandListEquals(a: vscode.Command[], b: vscode.Command[]): boolean { + if (a.length !== b.length) { + return false; + } + + for (let i = 0; i < a.length; i++) { + if (!commandEquals(a[i], b[i])) { + return false; + } + } + + return true; +} + export interface IValidateInput { (value: string, cursorPosition: number): vscode.ProviderResult; } @@ -390,6 +421,10 @@ class ExtHostSourceControl implements vscode.SourceControl { } set statusBarCommands(statusBarCommands: vscode.Command[] | undefined) { + if (this._statusBarCommands && statusBarCommands && commandListEquals(this._statusBarCommands, statusBarCommands)) { + return; + } + this._statusBarCommands = statusBarCommands; const internal = (statusBarCommands || []).map(c => this._commands.converter.toInternal(c)); -- GitLab