ide: insert whitespaces surrounding _ in macro expansion

This commit is contained in:
andylizi 2022-05-24 07:35:47 +08:00
parent 81805d4cfc
commit ebf8b1a96e
No known key found for this signature in database
GPG Key ID: BFBFA8C85929F0E8
2 changed files with 3 additions and 3 deletions

View File

@ -57,7 +57,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
|f: fn(SyntaxKind) -> bool, default| -> bool { last.map(f).unwrap_or(default) };
match tok.kind() {
k if is_text(k) && is_next(|it| !it.is_punct(), true) => {
k if is_text(k) && is_next(|it| !it.is_punct() || it == UNDERSCORE, false) => {
mods.push(do_ws(after, tok));
}
L_CURLY if is_next(|it| it != R_CURLY, true) => {
@ -118,5 +118,5 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
}
fn is_text(k: SyntaxKind) -> bool {
k.is_keyword() || k.is_literal() || k == IDENT
k.is_keyword() || k.is_literal() || k == IDENT || k == UNDERSCORE
}

View File

@ -385,7 +385,7 @@ fn main() {
"#,
expect![[r#"
foo
0 "#]],
0"#]],
);
}