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

No way to circumvent 'smart' comment continuation #12928

Closed
RalfJung opened this issue Aug 3, 2022 · 5 comments · Fixed by #12934
Closed

No way to circumvent 'smart' comment continuation #12928

RalfJung opened this issue Aug 3, 2022 · 5 comments · Fixed by #12934

Comments

@RalfJung
Copy link
Member

RalfJung commented Aug 3, 2022

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"
    },
]
@jhgg
Copy link
Contributor

jhgg commented Aug 3, 2022

Unless you have onEnter command registered you shouldn't be getting rust analyzer's behavior here. Could be that this may be another extension or vscode configuration?

If you have many extensions you can try and find which one might be introducing this functionality via extension bisecting: https://code.visualstudio.com/blogs/2021/02/16/extension-bisect

@RalfJung
Copy link
Member Author

RalfJung commented Aug 3, 2022

I have disabled all extensions except for RA GitLens, ErrorLens.

Not sure which vscode setting could be relevant here?

// Place your settings in this file to overwrite the default settings
{
    "workbench.colorTheme": "Default Light+",
    "typescript.check.npmIsInstalled": false,
    "editor.mouseWheelScrollSensitivity": 2,
    "telemetry.telemetryLevel": "off",
    "files.watcherExclude": {
        "**/target/**": true
    },
    "rewrap.wrappingColumn": 100,
    "gitlens.codeLens.enabled": false,
    "gitlens.currentLine.enabled": false,
    "gitlens.hovers.currentLine.over": "line",
    "gitlens.statusBar.command": "gitlens.toggleFileBlame",
    "gitlens.hovers.avatars": false,
    "gitlens.views.fileHistory.avatars": false,
    "gitlens.views.repositories.avatars": false,
    "gitlens.views.lineHistory.avatars": false,
    "gitlens.views.search.avatars": false,
    "gitlens.blame.avatars": false,
    "gitlens.menus": {
        "editor": false,
        "editorGroup": {
            "blame": true,
            "compare": true
        },
        "editorTab": {
            "clipboard": true,
            "compare": true,
            "history": true,
            "remote": true
        },
        "explorer": {
            "clipboard": true,
            "compare": true,
            "history": true,
            "remote": true
        },
        "scmGroup": {
            "compare": true,
            "openClose": true,
            "stash": true,
            "stashInline": true
        },
        "scmItem": {
            "clipboard": true,
            "compare": true,
            "history": true,
            "remote": true,
            "stash": true
        }
    },
    "gitlens.advanced.telemetry.enabled": false,
    "extensions.ignoreRecommendations": true,
    "rust-analyzer.lens.enable": false,
    "rust-analyzer.cargo.buildScripts.enable": false,
    "rust-analyzer.procMacro.enable": false,
    "rust-analyzer.diagnostics.disabled": [
        "unlinked-file", // I guess for "normal" projects unlinked files are strange, for me they are common
        "missing-match-arm", // https://github.com/rust-lang/rust-analyzer/issues/4896
        "type-mismatch", // https://github.com/rust-lang/rust-analyzer/issues/1109
        "unresolved-module", // https://github.com/rust-lang/rust-analyzer/issues/9173
        "unresolved-extern-crate", // https://github.com/rust-lang/rust-analyzer/issues/12926
    ],
    "rust-analyzer.checkOnSave.overrideCommand": [
        "cargo", "check", "--lib", "--bins", "--tests", "--examples", "--workspace", "--message-format=json"
    ],
    "editor.showUnused": false,
    "keyboard.dispatch": "keyCode",
    "files.exclude": {
        "**/.*.cache": true,
        "**/*.glob": true,
        "**/*.vos": true,
        "**/*.vok": true,
        "**/*.vo": true,
    },
    "editor.inlayHints.enabled": "offUnlessPressed",
    "editor.semanticTokenColorCustomizations": {
        "rules": {
            "*.unsafe:rust": "#eb5046"
        }
    },
    "editor.acceptSuggestionOnEnter": "off",
}

@jhgg
Copy link
Contributor

jhgg commented Aug 3, 2022

It is indeed rust-analyzer, but it is not the onEnter command, but rather the changes introduced in #10384 that added enter rules that are causing vscode to continue the comments.

cc @HKalbasi

@RalfJung
Copy link
Member Author

RalfJung commented Aug 3, 2022

For now I think #10384 should be reverted. There exists the rust-analyzer.onEnter handler to explicitly request automatic comment handling, so people that want to always have automatic comment handling can still easily opt-in to that.

@Veykril
Copy link
Member

Veykril commented Aug 3, 2022

I think a config is better here, the onEnter handler has several problems which is why #10384 came to be. I'll add a config for this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants