Skip to content

Format on type adds bracket incorrectly #11854

@Waqar144

Description

@Waqar144

Hi,

I am not a rust developer or a active rust-analyzer user but I work on a lsp client (Kate editor) and we got this bug report: https://bugs.kde.org/show_bug.cgi?id=452047

Consider the following simple rust code:

fn main() {
    |println!("hello");
}

| indicates caret position. If you have "Format on Type" enabled and ou press backspace enought times so that the lines wraps into the previous line and touches the { of the previous line, rust-analzyer suggests to add a bracket at the end of line resulting in

fn main() {|println!("hello");}
}

This led to an infinite loop in Kate (which has been fixed), but still it doesn't seem right that the LSP suggests to a bracket in that place.

rust-analyzer version: rust-analyzer bc08b8e 2022-03-28 stable

rustc version: rustc 1.51.0 (2fd73fabe 2021-03-23)

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