From 9623e77d9f24b6ff8e718f7321a92081997ea1e9 Mon Sep 17 00:00:00 2001 From: pcpthm Date: Fri, 22 Mar 2019 03:27:00 +0900 Subject: Fix reparsing bug when lex result is different --- crates/ra_syntax/src/parsing/reparsing.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index b44cca49d..3b5471bf8 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs @@ -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)> { - 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)) -- cgit v1.2.3