mirror of
https://github.com/coder/code-server.git
synced 2026-05-07 04:51:59 +02:00
Update to VS Code 1.52.1
This commit is contained in:
@@ -17,6 +17,7 @@ import { ISplice } from 'vs/base/common/sequence';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
||||
type ProviderHandle = number;
|
||||
type GroupHandle = number;
|
||||
@@ -90,6 +91,49 @@ function compareResourceStatesDecorations(a: vscode.SourceControlResourceDecorat
|
||||
return result;
|
||||
}
|
||||
|
||||
function compareCommands(a: vscode.Command, b: vscode.Command): number {
|
||||
if (a.command !== b.command) {
|
||||
return a.command < b.command ? -1 : 1;
|
||||
}
|
||||
|
||||
if (a.title !== b.title) {
|
||||
return a.title < b.title ? -1 : 1;
|
||||
}
|
||||
|
||||
if (a.tooltip !== b.tooltip) {
|
||||
if (a.tooltip !== undefined && b.tooltip !== undefined) {
|
||||
return a.tooltip < b.tooltip ? -1 : 1;
|
||||
} else if (a.tooltip !== undefined) {
|
||||
return 1;
|
||||
} else if (b.tooltip !== undefined) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (a.arguments === b.arguments) {
|
||||
return 0;
|
||||
} else if (!a.arguments) {
|
||||
return -1;
|
||||
} else if (!b.arguments) {
|
||||
return 1;
|
||||
} else if (a.arguments.length !== b.arguments.length) {
|
||||
return a.arguments.length - b.arguments.length;
|
||||
}
|
||||
|
||||
for (let i = 0; i < a.arguments.length; i++) {
|
||||
const aArg = a.arguments[i];
|
||||
const bArg = b.arguments[i];
|
||||
|
||||
if (aArg === bArg) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return aArg < bArg ? -1 : 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function compareResourceStates(a: vscode.SourceControlResourceState, b: vscode.SourceControlResourceState): number {
|
||||
let result = comparePaths(a.resourceUri.fsPath, b.resourceUri.fsPath, true);
|
||||
|
||||
@@ -97,6 +141,18 @@ function compareResourceStates(a: vscode.SourceControlResourceState, b: vscode.S
|
||||
return result;
|
||||
}
|
||||
|
||||
if (a.command && b.command) {
|
||||
result = compareCommands(a.command, b.command);
|
||||
} else if (a.command) {
|
||||
return 1;
|
||||
} else if (b.command) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result !== 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (a.decorations && b.decorations) {
|
||||
result = compareResourceStatesDecorations(a.decorations, b.decorations);
|
||||
} else if (a.decorations) {
|
||||
@@ -166,17 +222,13 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
|
||||
private _validateInput: IValidateInput | undefined;
|
||||
|
||||
get validateInput(): IValidateInput | undefined {
|
||||
if (!this._extension.enableProposedApi) {
|
||||
throw new Error(`[${this._extension.identifier.value}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${this._extension.identifier.value}`);
|
||||
}
|
||||
checkProposedApiEnabled(this._extension);
|
||||
|
||||
return this._validateInput;
|
||||
}
|
||||
|
||||
set validateInput(fn: IValidateInput | undefined) {
|
||||
if (!this._extension.enableProposedApi) {
|
||||
throw new Error(`[${this._extension.identifier.value}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${this._extension.identifier.value}`);
|
||||
}
|
||||
checkProposedApiEnabled(this._extension);
|
||||
|
||||
if (fn && typeof fn !== 'function') {
|
||||
throw new Error(`[${this._extension.identifier.value}]: Invalid SCM input box validation function`);
|
||||
@@ -223,8 +275,9 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
private _resourceHandlePool: number = 0;
|
||||
private _resourceStates: vscode.SourceControlResourceState[] = [];
|
||||
|
||||
private _resourceStatesMap: Map<ResourceStateHandle, vscode.SourceControlResourceState> = new Map<ResourceStateHandle, vscode.SourceControlResourceState>();
|
||||
private _resourceStatesCommandsMap: Map<ResourceStateHandle, vscode.Command> = new Map<ResourceStateHandle, vscode.Command>();
|
||||
private _resourceStatesMap = new Map<ResourceStateHandle, vscode.SourceControlResourceState>();
|
||||
private _resourceStatesCommandsMap = new Map<ResourceStateHandle, vscode.Command>();
|
||||
private _resourceStatesDisposablesMap = new Map<ResourceStateHandle, IDisposable>();
|
||||
|
||||
private readonly _onDidUpdateResourceStates = new Emitter<void>();
|
||||
readonly onDidUpdateResourceStates = this._onDidUpdateResourceStates.event;
|
||||
@@ -302,9 +355,16 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
const lightIconUri = r.decorations && getIconResource(r.decorations.light) || iconUri;
|
||||
const darkIconUri = r.decorations && getIconResource(r.decorations.dark) || iconUri;
|
||||
const icons: UriComponents[] = [];
|
||||
let command: ICommandDto | undefined;
|
||||
|
||||
if (r.command) {
|
||||
this._resourceStatesCommandsMap.set(handle, r.command);
|
||||
if (r.command.command === 'vscode.open' || r.command.command === 'vscode.diff') {
|
||||
const disposables = new DisposableStore();
|
||||
command = this._commands.converter.toInternal(r.command, disposables);
|
||||
this._resourceStatesDisposablesMap.set(handle, disposables);
|
||||
} else {
|
||||
this._resourceStatesCommandsMap.set(handle, r.command);
|
||||
}
|
||||
}
|
||||
|
||||
if (lightIconUri) {
|
||||
@@ -320,7 +380,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
const faded = r.decorations && !!r.decorations.faded;
|
||||
const contextValue = r.contextValue || '';
|
||||
|
||||
const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded, contextValue] as SCMRawResource;
|
||||
const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded, contextValue, command] as SCMRawResource;
|
||||
|
||||
return { rawResource, handle };
|
||||
});
|
||||
@@ -340,6 +400,8 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
for (const handle of handlesToDelete) {
|
||||
this._resourceStatesMap.delete(handle);
|
||||
this._resourceStatesCommandsMap.delete(handle);
|
||||
this._resourceStatesDisposablesMap.get(handle)?.dispose();
|
||||
this._resourceStatesDisposablesMap.delete(handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user