Skip to content

Commit

Permalink
prefix argument id with actual command (#165805)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 8, 2022
1 parent 391235a commit ed1bc56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ suite('CodeAction', () => {
},
tsLint: {
abc: {
$ident: 57,
$ident: 'funny' + 57,
arguments: <IMarkerData[]>[],
id: '_internal_command_delegation',
title: 'abc'
},
bcd: {
$ident: 47,
$ident: 'funny' + 47,
arguments: <IMarkerData[]>[],
id: '_internal_command_delegation',
title: 'bcd'
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ export interface ISuggestDataDto {
[ISuggestDataDtoField.additionalTextEdits]?: ISingleEditOperation[];
[ISuggestDataDtoField.kindModifier]?: languages.CompletionItemTag[];
// Command
[ISuggestDataDtoField.commandIdent]?: number;
[ISuggestDataDtoField.commandIdent]?: string;
[ISuggestDataDtoField.commandId]?: string;
[ISuggestDataDtoField.commandArguments]?: any[];
// not-standard
Expand Down Expand Up @@ -1640,7 +1640,7 @@ export interface IWorkspaceEditDto {
edits: Array<IWorkspaceFileEditDto | IWorkspaceTextEditDto | IWorkspaceCellEditDto>;
}

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

export interface ICodeActionDto {
cacheId?: ChainedCacheId;
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/api/common/extHostCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export const IExtHostCommands = createDecorator<IExtHostCommands>('IExtHostComma
export class CommandsConverter implements extHostTypeConverter.Command.ICommandsConverter {

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

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

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

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

if (typeof command.$ident === 'number') {
if (typeof command.$ident === 'string') {
return this._cache.get(command.$ident);

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

if (!actualCmd) {
return Promise.reject('actual command NOT FOUND');
return Promise.reject(`Actual command not found, wanted to execute ${args[0]}`);
}
return this._commands.executeCommand(actualCmd.command, ...(actualCmd.arguments || []));
}
Expand Down

0 comments on commit ed1bc56

Please sign in to comment.