-
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
fix global menu params to align to vscode #10198
Conversation
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.
Hi @shuyaqian, thank you for your contribution.
Do you mind explaining a bit more (in the What it does section of your PR) what issue your PR actully fixes? Perhaps even link an issue that already describes this problem.
packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts
Outdated
Show resolved
Hide resolved
This pr solves when I need to register a menu in "explorer/context" and want to execute the appropriate command when particular files are selected. Currently, the URIs of all files cannot be obtained when multiple files are selected in the Theia. However, the URIs can be obtained in the vscode. When a command is registered, the second parameter of the callback function obtains the URIs of all files. |
Signed-off-by: shuyaqian 717749594@qq.com
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 finally had some time to test this PR. The changes seem to work well, however, I'm a bit concerned with the type safety in there.
const selection = this.selectionService.selection; | ||
const resourceParams = []; |
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.
This is currently implicitely typed as being any[]
. Can you add an explicit type here (even if it's any[]
)?
const uri = this.resourceContextKey.get(); | ||
return uri ? uri['codeUri'] : undefined; | ||
if (TreeWidgetSelection.is(selection) && selection.source instanceof FileTreeWidget && selection.length > 1) { | ||
resourceParams.push(selection.map((item: any) => item.uri && item.uri.codeUri)); |
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.
This seems to work, but why can we assume that the selection items always contain a uri
? Can we add an in
check for the uri? This seems to be quite unsafe to me.
@shuyaqian do you still plan on working on the pull-request? |
Signed-off-by: shuyaqian 717749594@qq.com
What it does
This pr solves when I need to register a menu in "explorer/context" and want to execute the appropriate command when particular files are selected. Currently, the URIs of all files cannot be obtained when multiple files are selected in the Theia. However, the URIs can be obtained in the vscode. When a command is registered, the second parameter of the callback function obtains the URIs of all files.
How to test
registerCommand
in pluginReview checklist
Reminder for reviewers