-
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
plugins: view/title menus in all dock panel views #12763
Conversation
5bd2eec
to
ba614e0
Compare
In VS Code, contributions of menus to the "view/title" contribution point are supposed to be included in all views that are not editors, so long as the "when" condition (if any) is satisfied. So the contribution handler is updated to register the menu delegate in all non-editors. Fixes eclipse-theia#12705 Signed-off-by: Christian W. Damus <cdamus.ext@eclipsesource.com>
Commit fc12c9c amends the fix to include all views that are not editors, including views in the bottom panel and the secondary panel. The PR description is updated accordingly. |
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.
The change looks good to me and works well, thank you Christian!
From what I can see in the VS Code documentation on menu contributions, they only state that:
Contribute a menu item for a command to the editor or Explorer.
and as view they count anything that is contributed to the following view containers:
- explorer: Explorer view container in the Activity Bar
- scm: Source Control Management (SCM) view container in the Activity Bar
- debug: Run and Debug view container in the Activity Bar
- test: Test view container in the Activity Bar
- Custom view containers contributed by Extensions.
In the Theia documentation we mainly differentiate between editor and view, so any widget not being an editor is a view. Therefore, I agree that view title menu contributions in Theia should appear on any non-editor widget and not be restricted to the ones that VS Code offers.
@colin-grant-work What do you think? You did a lot of refactoring in this area "recently" with this PR: #11290
Thanks, Martin. That was the basis of my thinking in the revised version of this PR. The only reservation that I have, because the general expectation would be that extensions are designed for VS Code and not for Theia, is that perhaps it will be surprising to see them appearing also on the left-side dock container, where in VS Code they do not appear. If there's a reliable way to identify that container, to exclude the contribution from it, I'd be happy to employ it. |
@cdamus The application shell has a method called getAreaFor that returns the area in which a widget resides, do you think that could be helpful? I understand that we want VS Code compatibility but I assume our where conditions also support more options. In any case, I think this is maybe a discussion that should also involve other people. Whatever the decision, it should be documented somehow. |
@msujew @vince-fugnitto @tsmaeder opinions? |
I believe keeping it as consistent as possible with VS Code would be a good base implementation, where the contribution would only apply for non-editor widgets. The behavior at the moment is a little inconsistent as in VS Code I believe they treat anything in the main-panel as "editors" while we display the contribution (ex: welcome page, markdown preview). It might also not be super critical since it's likely bad practice for a plugin to pollute the application with toolbar contributions everywhere (it would at least annoy most users anyways). |
Thanks, Vince.
That is a good point and seems not difficult to accommodate, given that we can determine that a widget is in this area.
I can imagine that there are actions legitimately applicable to all views, especially things relating to workspace layout and accessibility concerns. |
Commit bf4bd5c makes this further refinement to the contribution logic, to exclude also non-editors that are in the
|
@cdamus I'm not sure it's as simple as completely disregarding the |
From my point of view, it is very hard to estimate what users would expect. However, I'd argue that the original "non-editor" implementation was a bit more predictable than the "non-main area" implementation. I understand that pollution is a topic that may concern users but isn't that also true within VS Code? If a plugin author does not properly use the |
Indeed, internal consistency in Theia should be more important than elusive (and illusory) consistency with VS Code. So I've reverted back to commit fc12c9c which just contributes If we stipulate that every contributed widget is either an editor or a view, then it makes sense that the union of the |
@vince-fugnitto Would you be okay to define a view as everything that is not an editor, independent from its current location? Or how can we best continue with this PR? |
@martin-fleck-at I believe that both approaches would present differences in behavior compared to vscode since we fundamentally have a different behavior in our workbench compared to them without the their restrictions:
In the end I think non-editors should be fine, we just need to be aware that in the framework we would give the menu to views which otherwise do not have it in vscode. I also believe that it is the responsibility of a plugin to properly set the |
@vince-fugnitto Thank you! I agree that the non-editor approach is a bit more intuitive and consistent. I'll wait another day in case somebody else has a different opinion, otherwise I'll merge the PR. |
What it does
In VS Code, contributions of menus to the
"view/title"
contribution point are supposed to be included in all views in the dock panels, so long as the"when"
condition (if any) is satisfied. So the contribution handler is updated to register the menu delegate for all non-editor views.Fixes #12705
How to test
Per the directions in the description of #12705:
menu_bug_4
branch of the OP's sample repository and build themyext
extension.plugins/
directory and launch Theia.where
Subsequently, verify that by use of the
"when"
condition on the contribution this action can be restricted to selected views. For example:Review checklist
Reminder for reviewers