mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Fix reparsing bug when lex result is different
This commit is contained in:
parent
c622000413
commit
9623e77d9f
3 changed files with 17 additions and 2 deletions
|
@ -33,10 +33,10 @@ pub(crate) fn incremental_reparse(
|
|||
}
|
||||
|
||||
fn reparse_leaf<'node>(
|
||||
node: &'node SyntaxNode,
|
||||
root: &'node SyntaxNode,
|
||||
edit: &AtomTextEdit,
|
||||
) -> Option<(&'node SyntaxNode, GreenNode, Vec<SyntaxError>)> {
|
||||
let node = algo::find_covering_node(node, edit.delete);
|
||||
let node = algo::find_covering_node(root, edit.delete);
|
||||
match node.kind() {
|
||||
WHITESPACE | COMMENT | IDENT | STRING | RAW_STRING => {
|
||||
let text = get_text_after_edit(node, &edit);
|
||||
|
@ -50,6 +50,13 @@ fn reparse_leaf<'node>(
|
|||
return None;
|
||||
}
|
||||
|
||||
if let Some(next_char) = root.text().char_at(node.range().end()) {
|
||||
let tokens_with_next_char = tokenize(&format!("{}{}", text, next_char));
|
||||
if tokens_with_next_char.len() == 1 {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
let green = GreenNode::new_leaf(node.kind(), text.into());
|
||||
let new_errors = vec![];
|
||||
Some((node, green, new_errors))
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
0
|
||||
1
|
||||
|
||||
bb"
|
|
@ -0,0 +1,4 @@
|
|||
1
|
||||
1
|
||||
|
||||
""!
|
Loading…
Add table
Add a link
Reference in a new issue