Skip to content

No way to circumvent 'smart' comment continuation #12928

@RalfJung

Description

@RalfJung

When my cursor is at the end of a doc comment line (//! foo), no matter whether I hit Enter or Shift-Enter, RA tries to be 'smart' and insert a //! into the next line. That is quite annoying, I often want to type something else after the doc comment! I don't know why RA thinks it can guess whether I want to continue the comment or not; that is inherently unknoweable and should be indicated explicitly by the user (e.g., other editors use Enter for just a plain newline and Shift-Enter for smart newline with comments).

The documentation in https://github.com/lnicola/rust-analyzer/blob/master/crates/ide/src/typing/on_enter.rs indicates that I need to configure something to get RA's smart enter behavior. However I have deliberately not configured this, and still I am getting the 'smart' behavior.

@bjorn3 once told me that Shift-Enter is a way to bypass smart enter handling by extensions, but it doesn't have any effect here -- even Shift-Enter.

Is there a way to opt-out of this 'smart' behavior?

// Place your key bindings in this file to overwrite the defaults
[
    /*{
        "command": "rust-analyzer.onEnter",
        "key": "shift+enter",
        "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust"
    },*/
    // Use Ctrl-shift-s for 'save all', not 'save as'.
    {
        "key": "ctrl+shift+s",
        "command": "-workbench.action.files.saveAs"
    },
    {
        "key": "ctrl+shift+s",
        "command": "workbench.action.files.saveAll"
    },
    // Make Ctrl-tab order make more sense.
    {
        "key": "ctrl+tab",
        "command": "workbench.action.nextEditorInGroup"
    },
    {
        "key": "ctrl+shift+tab",
        "command": "workbench.action.previousEditorInGroup"
    },
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions