I write a vscode plugin to support a function that could add two commands when right click different types files. It works very well in vscode, but not work in theia extension. The question is in vscode I set different "when" labels to add the different types of buttons, but the "when" labels work disorderly,it confused. By the way, the event I set is to click the button I add to open a url, it totally doesn't work in theia extension.
1.add some codes in package.json (add some labels i.e "menus" "when")
OS and Theia version:
1.The newest theia master branch codes
2.Docker version 1.12.6
Diagnostics:
I wonder whether the support in vscode plugins could work better in theia extension.
@ouyangxizi Could you provide a VS Code extension to reproduce? We need to understand what you mean by the "when" labels work disorderly,it confused.. An example would be very helpful.
By the way, the event I set is to click the button I add to open a url, it totally doesn't work in theia extension.
I'm also not sure what you mean here. An example would help as well, please.
@akosyakov
The main codes I add in package.json are below:
"menus":{
"explorer/context":[
{
"when":"resourceExtname == .bpm",
"command":"extension.bpm"
},
{
"when":"resourceExtname == .yaml",
"command":"extension.yaml"
}
]
}
I'd like to right click bpm file and there will be added a button, and right click yaml file and there will be added a button different with the previous button. But in theia extension the two buttons appear disorderly. I wonder the "when" label is not stable in theia?
@akosyakov
By the way, the event I set is to click the button I add to open a url, it totally doesn't work in theia extension.
It means I write codes to implement a function that click a button then there will open a website in default browser. But it doesn't work in theia when work perfectly in vscode.
@ouyangxizi it should be stable, maybe a bug. Which version of Theia do you use?
@ouyangxizi it should be stable, maybe a bug. Which version of Theia do you use?
@akosyakov
I use the newest master branch theia, compile the source code and make a image in docker.
@ouyangxizi thank you, i will investigate now
It means I write codes to implement a function that click a button then there will open a website in default browser. But it doesn't work in theia when work perfectly in vscode.
Could you provide an implementation please?
@akosyakov
The codes below is the main function I write to open a uri in default browser.
export const openDefault = (path: any): void =>{
let uri = "http://xx.xxxx.com/xxx/xxx.html";
const browser = standardizedBrowserName(defaultBrowser());
open(uri, browser);
};
Thanks for your quick response~
And you running Theia in electron right? For browser I doubt it can work, extensions are running on the backend.
And you running Theia in electron right? For browser I doubt it can work, extensions are running on the backend.
@akosyakov
Do you mean that the way to add .vsix in plugins directory only could run in the backend? If it is, I will consider another way to implement the OpenInDefaultBrowser function.
@ouyangxizi
You can open url by doing
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://theia-ide.org'))
with new ongoing API it should be possible to do
vscode.env.openExternal(vscode.Uri.parse('https://theia-ide.org'))
VS Code extensions needs access to backend tools like nodejs. You can try to use vscode.open command instread and pass http url.
@ouyangxizi
You can open url by doingvscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://theia-ide.org'))with new ongoing API it should be possible to do
vscode.env.openExternal(vscode.Uri.parse('https://theia-ide.org'))
Appreciate for your advice,it's worked for me.
@ouyangxizi
You can open url by doingvscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://theia-ide.org'))with new ongoing API it should be possible to do
vscode.env.openExternal(vscode.Uri.parse('https://theia-ide.org'))
@benoitf
I test it in vscode, it's worked for me. But back up as a .vsix in theia, The function jumping to the url doesn't happen in theia. I wonder where should I put these codes?
How can I add a event that could click a button and jump to another tab in theia?
Thanks for your help!
VS Code extensions needs access to backend tools like nodejs. You can try to use vscode.open command instread and pass http url.
@akosyakov
Hi~One more question waiting for your help!
I found mini-browser in theia, that's exactly what I want in theia to open a url. How can I call the mini-browser API in vscode extension? I have read a lot of documents and discusses in Spectrum, still cannot solve this problem.
Using the codes below, cannot open url in theia:
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://theia-ide.org'));
Looking forward for your help!
Most helpful comment
@ouyangxizi
You can open url by doing
with new ongoing API it should be possible to do