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

[contributes.menus] how to show menu only in editor not Output window #12263

Closed
formulahendry opened this issue Sep 19, 2016 · 15 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@formulahendry
Copy link
Member

I have an extension which contributes a menu in context menu of editor. However, the menu also shows in the Output window. How could I make it only show in editor. BTW, the menu shows in Output window but not in Debug Console or Integrated Terminal. Is it bug or by design?

@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Sep 20, 2016
@chrmarti
Copy link
Contributor

The package.json seems to correctly target only the editor:

        "menus": {
            "editor/context": [
                {
                    "command": "code-runner.run",
                    "group": "navigation"
                }
            ]
        },

@jrieken
Copy link
Member

jrieken commented Sep 20, 2016

@formulahendry You can use the where clause to limit the showings of the context menu. Our markdown extension for instances does that. However, we lack context keys to signal that we are in the output channel or debug repl. Maybe a good starting point for you would be to check for a selection like so "when": "editorHasSelection"

cc @isidorn to check if we have a context key that ala inDebugRepl?

@jrieken jrieken added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Sep 20, 2016
@formulahendry
Copy link
Member Author

editorHasSelection is when there are selections of some text, right? However, I want the menu always to be shown in editor, but not Output window.

@isidorn
Copy link
Contributor

isidorn commented Sep 20, 2016

We have the key inDebugRepl, however we currently do not have inOutput - though we could add it if needed.

@jrieken jrieken assigned isidorn and unassigned jrieken Sep 20, 2016
@jrieken
Copy link
Member

jrieken commented Sep 20, 2016

Assigning @isidorn for the inOutput context key. @formulahendry Until then you can use trick which is to check for the editor language id like so "when": "editorLangId != Log"but note that we will allow to set the language for an output channel in the future, breaking that trick

@formulahendry
Copy link
Member Author

Hi, I use vs code 1.6 with below config but the menu still shows in output window. Any idea?

        "menus": {
            "editor/context": [
                {
                    "when": "!inOutput",
                    "command": "code-runner.run",
                    "group": "navigation"
                }
            ]
        }

@isidorn
Copy link
Contributor

isidorn commented Oct 12, 2016

@formulahendry this should work as assigning simple keyboard shortcuts with the "when": "!inOutput" - works fine for me.
@jrieken any suggestions?

@formulahendry
Copy link
Member Author

I update the extension
code-runner-0.3.4.zip
with below changes:
image

But the 'Run Code' still shows when I right-click in the Output Window area.

@formulahendry
Copy link
Member Author

Seems like it only works in keybindings but not in menus
image

@formulahendry
Copy link
Member Author

Hi, any idea on this?

@jrieken
Copy link
Member

jrieken commented Oct 19, 2016

@isidorn It depends with what context service you create the editor widget. It must be the same that manages the inOutput key

@isidorn
Copy link
Contributor

isidorn commented Oct 24, 2016

Sorry for the slow reply - I was working on an isolated branch.

@jrieken currently I just use the scoped context key service like this
This nicely works for the keybinding, however the bottom line issue is probably that scoped editor service is not used by the menu. I can not use the global context key service to manage my key since then my key will be always enabled no matter if my element has focus or not.

So it seems that I have to make the workbench create my editor using a scoped context service which I am not sure if is possible. Can investigate but let me know if I am missing something obvious here...

@jrieken
Copy link
Member

jrieken commented Oct 24, 2016

Where/How do you pass on that scoped service instance to the editor?

@isidorn
Copy link
Contributor

isidorn commented Oct 24, 2016

Well I do not pass it currently. It is enough for the scoped service to be created on the appropriate HTML element and everything seems to work just fine for the keybindings.

@jrieken jrieken reopened this Oct 24, 2016
@jrieken jrieken added bug Issue identified by VS Code Team member as probable bug and removed feature-request Request for new features or functionality labels Oct 24, 2016
@jrieken
Copy link
Member

jrieken commented Oct 24, 2016

You should because otherwise those keys aren't visible (as you see with the context menu). My knowledge might be outdated after @alexandrudima last refactoring but if you create a child context and don't pass it on to the editor its key/value entries aren't visible to the editor.

@isidorn isidorn added this to the November 2016 milestone Oct 24, 2016
@roblourens roblourens added the verified Verification succeeded label Oct 27, 2016
@roblourens roblourens added this to the October 2016 milestone Oct 27, 2016
@roblourens roblourens removed this from the November 2016 milestone Oct 27, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants