Skip to content

Enhanced enter key / onEnter erroneously deletes/interprets $foo occurring on the same line #22596

Description

@kpreid

rust-analyzer version: 0.4.2938-standalone (888f581 2026-06-15)

editor or extension: VSCode, extension version 0.4.2938

code snippet to reproduce:

macro_rules! foo {
    ($bar:tt) => {
        const { $bar }
    };
}
  1. Place the cursor immediately to the right of const { on the third line.
  2. Press Enter (invoke rust-analyzer.onEnter)

The result is:

macro_rules! foo {
    ($bar:tt) => {
        const {
            
        }
    };
}

The tokens $bar have been deleted, but should not be. This appears to happen to any occurrences of the text $ followed by an identifier or number which are to the right of a {. Also, if it is the text $0, then an additional cursor appears there. This suggests that the problem is incorrect escaping of replacement text passed to VS Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-idegeneral IDE featuresC-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions