Add another case to the syntax fixup code

This commit is contained in:
Florian Diebold 2022-03-03 18:29:40 +01:00
parent a55dd29e88
commit ac51eea309

View File

@ -97,6 +97,18 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
]);
}
},
ast::LetStmt(it) => {
if it.semicolon_token().is_none() {
append.insert(node.clone(), vec![
SyntheticToken {
kind: SyntaxKind::SEMICOLON,
text: ";".into(),
range: end_range,
id: EMPTY_ID,
},
]);
}
},
_ => (),
}
}
@ -229,6 +241,34 @@ fn foo () {a . __ra_fixup ; bar () ;}
)
}
#[test]
fn incomplete_let() {
check(
r#"
fn foo() {
let x = a
}
"#,
expect![[r#"
fn foo () {let x = a ;}
"#]],
)
}
#[test]
fn incomplete_field_expr_in_let() {
check(
r#"
fn foo() {
let x = a.
}
"#,
expect![[r#"
fn foo () {let x = a . __ra_fixup ;}
"#]],
)
}
#[test]
fn field_expr_before_call() {
// another case that easily happens while typing