Skip to content

Commit ed1bc56

Browse files
authored
prefix argument id with actual command (microsoft#165805)
microsoft#165244 (comment)
1 parent 391235a commit ed1bc56

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/vs/editor/contrib/codeAction/test/browser/codeAction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ suite('CodeAction', () => {
8080
},
8181
tsLint: {
8282
abc: {
83-
$ident: 57,
83+
$ident: 'funny' + 57,
8484
arguments: <IMarkerData[]>[],
8585
id: '_internal_command_delegation',
8686
title: 'abc'
8787
},
8888
bcd: {
89-
$ident: 47,
89+
$ident: 'funny' + 47,
9090
arguments: <IMarkerData[]>[],
9191
id: '_internal_command_delegation',
9292
title: 'bcd'

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ export interface ISuggestDataDto {
15661566
[ISuggestDataDtoField.additionalTextEdits]?: ISingleEditOperation[];
15671567
[ISuggestDataDtoField.kindModifier]?: languages.CompletionItemTag[];
15681568
// Command
1569-
[ISuggestDataDtoField.commandIdent]?: number;
1569+
[ISuggestDataDtoField.commandIdent]?: string;
15701570
[ISuggestDataDtoField.commandId]?: string;
15711571
[ISuggestDataDtoField.commandArguments]?: any[];
15721572
// not-standard
@@ -1640,7 +1640,7 @@ export interface IWorkspaceEditDto {
16401640
edits: Array<IWorkspaceFileEditDto | IWorkspaceTextEditDto | IWorkspaceCellEditDto>;
16411641
}
16421642

1643-
export type ICommandDto = { $ident?: number } & languages.Command;
1643+
export type ICommandDto = { $ident?: string } & languages.Command;
16441644

16451645
export interface ICodeActionDto {
16461646
cacheId?: ChainedCacheId;

src/vs/workbench/api/common/extHostCommands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export const IExtHostCommands = createDecorator<IExtHostCommands>('IExtHostComma
323323
export class CommandsConverter implements extHostTypeConverter.Command.ICommandsConverter {
324324

325325
readonly delegatingCommandId: string = `__vsc${Date.now().toString(36)}`;
326-
private readonly _cache = new Map<number, vscode.Command>();
326+
private readonly _cache = new Map<string, vscode.Command>();
327327
private _cachIdPool = 0;
328328

329329
// --- conversion between internal and api commands
@@ -367,7 +367,7 @@ export class CommandsConverter implements extHostTypeConverter.Command.ICommands
367367
// we have a contributed command with arguments. that
368368
// means we don't want to send the arguments around
369369

370-
const id = ++this._cachIdPool;
370+
const id = `${command.command}/${++this._cachIdPool}`;
371371
this._cache.set(id, command);
372372
disposables.add(toDisposable(() => {
373373
this._cache.delete(id);
@@ -386,7 +386,7 @@ export class CommandsConverter implements extHostTypeConverter.Command.ICommands
386386

387387
fromInternal(command: ICommandDto): vscode.Command | undefined {
388388

389-
if (typeof command.$ident === 'number') {
389+
if (typeof command.$ident === 'string') {
390390
return this._cache.get(command.$ident);
391391

392392
} else {
@@ -408,7 +408,7 @@ export class CommandsConverter implements extHostTypeConverter.Command.ICommands
408408
this._logService.trace('CommandsConverter#EXECUTE', args[0], actualCmd ? actualCmd.command : 'MISSING');
409409

410410
if (!actualCmd) {
411-
return Promise.reject('actual command NOT FOUND');
411+
return Promise.reject(`Actual command not found, wanted to execute ${args[0]}`);
412412
}
413413
return this._commands.executeCommand(actualCmd.command, ...(actualCmd.arguments || []));
414414
}

0 commit comments

Comments
 (0)