Skip to content

Linux: commands with keybindings ignore when clause of the command if defined #26318

Closed

Description

Version: 1.12.1
OS: Windows 10

I have the following keybinding:

    {
        "key": "ctrl+enter",
        "command": "workbench.action.toggleZenMode",
        "when": "editorTextFocus"
    }

When I am using git and I am entering a commit message, by pressing ctrl+enter to commit the message, the editor commits it but it also goes into zen mode. Based on my when statement, it shouldn't do that since I am using editorTextFocus.

Activity

  1. alexdima commented on May 10, 2017

    @alexdima
    Member

    I could reproduce on Linux.
    It is happening because Toggle Zen Mode is in the menus. i.e. the Toggle Zen Mode action is triggered via electron's menus keybinding listeners and via ipc, not via the keybindings service.

    image

    image

  2. added
    bug
    on May 10, 2017
  3. alexdima commented on May 10, 2017

    @alexdima
    Member

    Benjamin Pasero (@bpasero) I am not sure what the fix should be. We would need to know if a menu action got triggered by the menus via electron's keybindings listener and re-evaluate the when condition (as opposed to getting triggered via mouse click or selecting it via keyboard).

    i.e. in other words, showing a keybinding next to a menu action means adding a keybinding in our system without the when condition since Electron dispatches it and then we blindly execute the action without evaluating the when condition.

  4. bpasero commented on May 10, 2017

    @bpasero
    Contributor

    As far as I know there is no way for us to know if a menu item was triggered via mouse of keybinding. There is an event object on the menu item (https://github.com/electron/electron/blob/master/docs/api/menu-item.md#new-menuitemoptions) but this one only seems to be triggered when clicked via mouse and not when triggered via keybinding.

  5. added
    upstream
    on May 10, 2017
  6. changed the title [-]ctrl+enter is executing keybinding in "Source Control" message to commit[/-] [+]Linux: commands with keybindings ignore when clause of the command if defined[/+] on May 10, 2017
  7. bpasero commented on Nov 13, 2017

    @bpasero
    Contributor

    Marking as duplicate of #35225

  8. added
    *duplicate
    on Nov 13, 2017
  9. locked and limited conversation to collaborators on Dec 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicatebugupstream

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions