mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
use has_semi
This commit is contained in:
parent
5e35f191fc
commit
4dd7ec94bc
1 changed files with 4 additions and 5 deletions
|
@ -20,16 +20,15 @@ pub fn introduce_variable<'a>(ctx: AssistCtx) -> Option<Assist> {
|
||||||
|
|
||||||
buf.push_str("let var_name = ");
|
buf.push_str("let var_name = ");
|
||||||
expr.syntax().text().push_to(&mut buf);
|
expr.syntax().text().push_to(&mut buf);
|
||||||
let is_full_stmt = if let Some(expr_stmt) = ast::ExprStmt::cast(anchor_stmt) {
|
let full_stmt = ast::ExprStmt::cast(anchor_stmt);
|
||||||
|
let is_full_stmt = if let Some(expr_stmt) = full_stmt {
|
||||||
Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax())
|
Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax())
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
if is_full_stmt {
|
if is_full_stmt {
|
||||||
if let Some(last_child) = expr.syntax().last_child() {
|
if !full_stmt.unwrap().has_semi() {
|
||||||
if last_child.kind() != SEMI && !is_semi_right_after(expr.syntax()) {
|
buf.push_str(";");
|
||||||
buf.push_str(";");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
edit.replace(expr.syntax().range(), buf);
|
edit.replace(expr.syntax().range(), buf);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue