gye*_*seo 11 visual-studio-code vscode-extensions
例如,有两个VSCode扩展.
- extension1是注册命令'exCommand1'.
- extension2是注册命令'exCommand2'.
VSCode扩展可以调用命令.
(参考:https://code.visualstudio.com/docs/extensionAPI/vscode-api)
executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>
Run Code Online (Sandbox Code Playgroud)
如果API Doc是正确的那么..
extension1 can call extension2's 'exCommand2'. and
extension2 can call extension1's 'exCommand1'.
Run Code Online (Sandbox Code Playgroud)
可能吗?
VSCode的扩展名为Lazy Loading ...
如果可以进行inter extension的命令调用,那么如何将扩展加载到另一个扩展?
Mes*_*esh 13
我知道这是一个老帖子,如果你仍然有相同的要求或其他人谷歌搜索,这就是我做的.
var xmlExtension = vscode.extensions.getExtension( 'DotJoshJohnson.xml' );
// is the ext loaded and ready?
if( xmlExtension.isActive == false ){
xmlExtension.activate().then(
function(){
console.log( "Extension activated");
// comment next line out for release
findCommand();
vscode.commands.executeCommand("xmlTools.formatAsXml");
},
function(){
console.log( "Extension activation failed");
}
);
} else {
vscode.commands.executeCommand("xmlTools.formatAsXml");
}
// dev helper function to dump all the command identifiers to the console
// helps if you cannot find the command id on github.
var findCommand = function(){
vscode.commands.getCommands(true).then(
function(cmds){
console.log("fulfilled");
console.log(cmd);
},
function() {
console.log("failed");
console.log(arguments);
}
)
};
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1400 次 |
最近记录: |