Skip to content
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

Cell context menu should use NotebookCell as context like the cell toolbar #162018

Open
rebornix opened this issue Sep 27, 2022 · 6 comments
Open
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-celltoolbar
Milestone

Comments

@rebornix
Copy link
Member

The cell context menu in notebook editor is using UriComponents as context, but the cell toolbar is using NotebookCell. Since we populate commands from cell toolbar to the cell context menu, those commands won't work in cell context menu. We should have them aligned.

@roblourens
Copy link
Member

roblourens commented Dec 18, 2022

I don't think we have any way to customize this, the editor controls the context and all editor context menu actions have the same context

const groups = menu.getActions({ arg: model.uri });

We could handle this for builtin commands, but for commands from extensions, it would still be better to give the same context as the cell toolbar. Maybe we could register a wrapper action for every command in the cell toolbar that translates the context and executes the real command? Or we have to plumb a way for the editor to let us change the context of some menu items or something like that which seems awkward. Any other ideas @rebornix @jrieken?

@jrieken
Copy link
Member

jrieken commented Dec 19, 2022

I think using NotebookCell for the editor/context menu is undesirable and unexpected. Today things "just work" - meaning a normal editor command also works in notebooks because it is just text editors/documents. The contract for the context menu shouldn't not be changed. This similar to how the editor context menu for output channels isn't the output channel object but also its uri.

@roblourens
Copy link
Member

I'm not saying that all editor commands should have a different context- only commands that end up in the "Notebook Cell" submenu automatically as a result of being contributed to the cell title menu:

The result would be that a notebook command gets the same context whether it was invoked from the cell title toolbar or from the cell context menu. Other editor commands wouldn't be affected.

We can also say that commands will get a different context depending on which menu they are invoked from, but it seems nicer to be consistent especially if extensions will contribute to the toolbar and not test the command in the context menu, then they don't work there (as in microsoft/vscode-jupyter#7751)

@jrieken
Copy link
Member

jrieken commented Dec 20, 2022

Oh, now I get it. Unsure what/how to do it. Why do we have this menu at all? It seems weird to duplicate a title menu into the context menu

@rebornix
Copy link
Member Author

I can see the value of having notebook cell actions in the editor context menu as users would always get those actions no matter if they right click on cell container, or cell editor. My original issue was about aligning the context for Cell container context menu (right click on cell container/chrome), which is different from the cell editor context menu.

I'm not convinced that we want to change how we populate context for editor context menu so thinking about this again, I think it's fine that cell commands' context is NotebookCell | Uri | undefined. Leaving to @roblourens for the final call.

@rebornix rebornix removed their assignment Dec 20, 2022
@roblourens
Copy link
Member

My original issue was about aligning the context for Cell container context menu (right click on cell container/chrome), which is different from the cell editor context menu.

Oh, I didn't even pick up on that.

I'm not convinced that we want to change how we populate context for editor context menu so thinking about this again, I think it's fine that cell commands' context is NotebookCell | Uri | undefined.

I think that's ok, if only because we don't have a good solution to customizing the context for editor cell commands. Then for this issue I'll just fix commands to work with a Uri context. These menu contexts aren't really documented for extensions though, right? It's a bit tricky to work it out by experimenting.

It seems weird to duplicate a title menu into the context menu

You can even hide the toolbar 😭

@roblourens roblourens modified the milestones: February 2023, March 2023 Feb 21, 2023
@roblourens roblourens modified the milestones: March 2023, April 2023 Mar 21, 2023
@roblourens roblourens modified the milestones: April 2023, May 2023 Apr 26, 2023
@roblourens roblourens modified the milestones: May 2023, June 2023 May 31, 2023
@roblourens roblourens modified the milestones: June 2023, Backlog Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug notebook-celltoolbar
Projects
None yet
Development

No branches or pull requests

4 participants