This repository has been archived by the owner on Jan 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Marcel Kloubert edited this page Oct 31, 2017
·
12 revisions
Changes [↑]
Since version 2.x [↑]
Since Version 2 there is an important change in the execution of scripts:
All scripts are wrapped into a Promise now:
var vscode = require('vscode');
vscode.commands.registerCommand('myCommand', function() {
return new Promise(function(resolve, reject) {
try {
// your script is executed here
//
// at the end, the 'resolve()' callback is
// called and the result of your 'execute()'
// function is submitted to that callback
//
// IF YOU RETURN A PROMISE:
// the result or the error value of your Promise
// will be submitted to 'resolve()' and 'reject()'
// automatically
}
catch (e) {
reject(e); // catch any exception and submit
// it to 'reject()' callback
}
});
});
This makes it possible now to also use the error callback of executeCommand function:
var vscode = require('vscode');
vscode.commands.executeCommand('myCommand').then(function(res) {
// result of your script is stored in 'res' now
// what means, that you can return anything in your script now
}, function(err) {
// handle error your script
// has thrown or returned
});
In most cases there should be NO problem, if you use scripts that are written for Version 1.x, but you should check this out first!