-
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
Expanding Submenus contribution support #9371
Conversation
148a1e4
to
83702e4
Compare
83702e4
to
6fcf092
Compare
@vince-fugnitto @kittaakos @akosyakov , Anyone else... |
6fcf092
to
487d86b
Compare
I will take a look tomorrow morning. |
@EstherPerelman, I'm reading over the code now. In your PR description, you say
Do you have a plugin with which to test the code, or should it be possible to copy that code into any plugin's |
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 believe this is working well. I've confirmed that the JSON manifest provided produces the menus that it should. I have some questions about the code and some suggestions for how it might be made more legible. Let me know what you think of those ideas.
packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts
Show resolved
Hide resolved
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
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
Thank you for reviewing, It is possible to copy this code to any plugin's |
37fda8f
to
16b3e36
Compare
@colin-grant-work I've updated code, Can you check if everything is OK? |
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.
Thanks for the changes. I'm now getting all of the items I expect, but there are some odd ordering effects. For example, the manifest I gave above to non-cyclical menu duplication now gives the following menus:
All of the menu items are present, but Custom Submenu 3
now appears before the other two items in custom submenu 1
even though it is listed after both of them. Are the items being sorted alphabetically (with capital letters preceding lower-case letters), and is that intentional?
There's also an odd effect that is likely beyond the scope of this PR where selecting certain submenus causes a flicker effect where items are highlighted from the menu root out to the leaf, and it can cause a failure when hovering a new submenu as focus is returned to the root menu and lost at the leaf.
You can see a couple of instances in that GIF where the focus is lost. It happened more frequently, but it's so brief that the GIF doesn't capture them all. The behavior occurs on master
as well (for example in the Sample Menu > Sample sub menu
in the example application in the electron version), so I don't believe it's a problem with this code.
packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/menus/menus-contribution-handler.ts
Show resolved
Hide resolved
Yes it is sorted, Look at this |
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 looks good to me. Thanks @EstherPerelman!
16b3e36
to
00e56b0
Compare
const parentSubmenusIds = new Set<string>(); | ||
|
||
return menus.reduce((children: MenuTree[], menuItem) => { | ||
if (menuItem.submenu) { | ||
if (parentSubmenusIds.has(menuItem.submenu)) { |
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 @colin-grant-work I updated the code because parentSubmenusIds
declaration was inside the reduce
so it didn't work as excepted, I found by chance that the menu was duplicated...
menus.forEach(menu => { | ||
if (group) { | ||
// Adding previous group to the start of current menu group. | ||
menu.group = `${group}/${menu.group || '_'}`; |
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.
Also updated default value for group
from ''
to '_'
(If there's no group the item should be at the end of the menu list - compared with VSCode)
Any objection to merging this one? I see it is approved by @colin-grant-work |
we will merge it this week if there's no objection |
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 verified the changes with the vscode-builtin-git
plugin, as well as the contributes.menus
described in the pull-request description and it seems to work as intended.
I also verified if there were any regressions with the different contributions points:
const tree: MenuTree[] = []; | ||
|
||
Object.keys(allMenus).forEach(location => { | ||
// Don't build menus tree for a submenu decleration at root. |
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.
typo: decleration
> declaration
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.
Thank you @vince-fugnitto, Fixed it.
Signed-off-by: Esther Perelman <Esther.Perelman@sap.com>
The changes should allow us to easily support new menu contribution points such as #9387 👍 |
Thanks for testing & verifying, Is that says you approve this PR? |
Since Red Hat initially implemented the |
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 according to the provided steps and with the vscode git plugin, works as expected.
Signed-off-by: Esther Perelman Esther.Perelman@sap.com
What it does
Enabling contribute submenus not only for "scm/title" menus, But also for all other available contribution menus
How to test
Contribute submenus in any extension package.json following this syntax
Duplicates and cycle submenus are prevented.
For the next code in Package.json:
The result is:

Review checklist
Reminder for reviewers