-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vscode built-in menus #4173
vscode built-in menus #4173
Conversation
packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts
Outdated
Show resolved
Hide resolved
command: string; | ||
title: string; | ||
category?: string; | ||
icon?: string | { light: string; dark: string; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello again: why here do we have icon light and icon dark ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we ignore and don't parse from package.json? https://github.com/Microsoft/vscode/blob/366bfe96bf2fe4cff37de895c3fa2ccb776eb621/extensions/markdown-language-features/package.json#L29-L36
What is your suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello, my question is why it's not IconUrl that you introduced there
export type IconUrl = string | { light: string; dark: string; };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PluginPackageCommand
is a format of raw command as it is defined by VS Code, with relative paths for icons. In order to download them, paths are converted into URLs served by hostedPlugin
entry point. A new type is introduced to make it clear that a string is a url, not a raw path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't be then URI instead of string for iconUrl ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but then we need to transfer such urls from backend to frontend, and decided to stick with strings as for other remote APIs.
05e62e2
to
4f5e0ef
Compare
@@ -40,7 +41,9 @@ export class CommandRegistryMainImpl implements CommandRegistryMain { | |||
this.delegate.registerCommand(command, { | |||
// tslint:disable-next-line:no-any | |||
execute: (...args: any[]) => { | |||
this.proxy.$executeCommand(command.id, ...args); | |||
// plugin command handlers cannot handle Theia URI, only VS Code URI | |||
const resolvedArgs = (args || []).map(arg => arg instanceof URI ? arg['codeUri'] : arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there is something not so neat around URI. AFAIK consumer should just use the object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not conflicting with https://github.com/theia-ide/theia/blob/master/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts#L46 ?
I don't think so. vscode.open
is called by a plugin, so URI should be converted from VS Code to Theia format.
I'm trying to handle the reverse case: when Theia calls a plugin command. In this case, plugin command handlers expect only URIs in VS Code format, so Theia URIs should be always converted.
Does it make sense? Do you know the better place for conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx @akosyakov for the reply. The location of the convert is still looking strange to me here.
AFAIK If someone is calling a plug-in then this is that part that need to convert to theia URI format, not theia plug-in checking if format that it is receiving is in a vscode format.
I'm afraid that we miss several converters. Here it is for Uri but what if there is another type, etc.
should it be inside RPC ? or is it mangled there https://github.com/theia-ide/theia/pull/4062/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK If someone is calling a plug-in then this is that part that need to convert to theia URI format, not theia plug-in checking if format that it is receiving is in a vscode format.
The core does not know that it calls a plug-in, it calls a menu command handler and pass URI of a selected resource to it. Usually it is fine. With plugin-in it is not, because they cannot handle such URIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code in command-registry-main
is a menu command handler from plugin-ins. Could you be more specific and suggest where it should be done if not here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest to register a synthetic command for menu items that translates URIs and then delegate to a plugin-in command handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have an example of failing test for this usecase ?
is it only for vs code extensions or for theia plug-ins ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akosyakov yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, moved to menus-contribution-handler: https://github.com/theia-ide/theia/pull/4173/files#diff-c111d7d3381b06ddff0ddb201236bec1
@azatsarynnyy mentioned that there are duplicate menu items with these changes, for example for https://github.com/Azure/vscode-kubernetes-tools/blob/master/package.json#L579-L588 even though |
@azatsarynnyy could you try again, i've removed a limitation to have only one menu item per a command. Since we have different contexts it does not make sense: 265c0e0 |
@akosyakov I've tested the PR with the latest version of the vscode k8s extension and it works well. I see no issues. |
265c0e0
to
3aaa72b
Compare
@svor Could you check please that registering code lenses from the vscode extensions still work? |
3aaa72b
to
1eee41e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with vscode java extension 0.37.0 and it works without unexpected problems
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
…rent contexts Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
1eee41e
to
e5c8ff9
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
@@ -1,9 +1,20 @@ | |||
# Change Log | |||
|
|||
## v0.3.20 | |||
## v0.4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix #4004
VS Code docs: https://code.visualstudio.com/api/references/contribution-points#contributes.menus
This PR alignes Theia menus with VS Code built-in menus:
navigator
menu group is always sorted to the topexplorer/context
editor/context
editor/title
debug/callstack/context
view/item/context
Out of scope, since there are not corresponding implementations in Theia:
editor/title/context
menu: [tabbar-toolbar] support context menus #4161view/title
support view title menu contributions #4174ALT
commands [menus] alternative command support #4162Testing:
One can test against this VS Code extension: https://github.com/akosyakov/vscode-menus
There is no API breaking changes, but menu constants were renamed. Is it a case for major release? @marcdumais-work @svenefftinge
Location of built-in explorer groups in Theia and VS Code: