diff --git a/extensions/vscode-api-tests/src/commands.test.ts b/extensions/vscode-api-tests/src/commands.test.ts index 182bc2f26a2..043e375cd6a 100644 --- a/extensions/vscode-api-tests/src/commands.test.ts +++ b/extensions/vscode-api-tests/src/commands.test.ts @@ -72,7 +72,7 @@ suite('commands namespace tests', () => { let virtualDocumentUri = Uri.parse('speciale://authority/path'); let title = 'A title'; - return commands.executeCommand('vscode.previewHtml', virtualDocumentUri, title).then(success => { + return commands.executeCommand('vscode.previewHtml', virtualDocumentUri, ViewColumn.Three, title).then(success => { assert.ok(success); registration.dispose(); }); diff --git a/src/vs/workbench/api/node/extHostApiCommands.ts b/src/vs/workbench/api/node/extHostApiCommands.ts index bb823b1ef82..e08410ddfbf 100644 --- a/src/vs/workbench/api/node/extHostApiCommands.ts +++ b/src/vs/workbench/api/node/extHostApiCommands.ts @@ -170,7 +170,7 @@ class ExtHostApiCommands { `, args: [ { name: 'uri', description: 'Uri of the resource to preview.', constraint: value => value instanceof URI || typeof value === 'string' }, - { name: 'column', description: '(optional) Column in which to preview.' }, + { name: 'column', description: '(optional) Column in which to preview.', constraint: value => typeof value === 'undefined' || (typeof value === 'number' && typeof types.ViewColumn[value] === 'string') }, { name: 'label', description: '(optional) An human readable string that is used as title for the preview.', constraint: v => typeof v === 'string' || typeof v === 'undefined' } ] }); diff --git a/src/vs/workbench/api/node/extHostCommands.ts b/src/vs/workbench/api/node/extHostCommands.ts index 8443632ce02..5d85a32f694 100644 --- a/src/vs/workbench/api/node/extHostCommands.ts +++ b/src/vs/workbench/api/node/extHostCommands.ts @@ -85,13 +85,20 @@ export class ExtHostCommands { if (!command) { return Promise.reject(`Contributed command '${id}' does not exist.`); } - try { - let {callback, thisArg, description} = command; - if (description) { - for (let i = 0; i < description.args.length; i++) { + + let {callback, thisArg, description} = command; + + if (description) { + for (let i = 0; i < description.args.length; i++) { + try { validateConstraint(args[i], description.args[i].constraint); + } catch (err) { + return Promise.reject(`Running the contributed command:'${id}' failed. Illegal argument '${description.args[i].name}' - ${description.args[i].description}`); } } + } + + try { let result = callback.apply(thisArg, args); return Promise.resolve(result); } catch (err) {