Skip to content

Keybinding when clause has context for extension is enabled/installed #132539

@kaleidawave

Description

@kaleidawave

Rust-analyzer's current technique for auto inserting comments is with the following custom keybinding:

{
    "key": "Enter",
    "command": "rust-analyzer.onEnter",
    "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust"
}

(from rust-lang/rust-analyzer#4980)

The problem is that if the rust-analyzer extension is not installed or is disabled, pressing enter in the editor (when all the when conditions are met) throws a error with ⚠ command 'rust-analyzer.onEnter' not found and prevents the default return insertion.

Currently there isn't a way to prevent this apart from remove the keybinding temporarily.

This could be solved by adding a new context object. I looked at the when contexts and there isn't a extension one available in editor? Maybe "when": "extensions.available.has('rust-analyzer') && ..." ...?

Alternatively could this be done automatically, could vscode see that the extension is not available and ignore this keybinding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions