diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index d54669a952..7e7f914f5e 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs @@ -39,6 +39,13 @@ fn reparse_leaf<'node>( let node = algo::find_covering_node(root, edit.delete); match node.kind() { WHITESPACE | COMMENT | IDENT | STRING | RAW_STRING => { + if node.kind() == WHITESPACE || node.kind() == COMMENT { + // removing a new line may extends previous token + if node.text().to_string()[edit.delete - node.range().start()].contains('\n') { + return None; + } + } + let text = get_text_after_edit(node, &edit); let tokens = tokenize(&text); let token = match tokens[..] { diff --git a/crates/ra_syntax/tests/data/reparse/fuzz-failures/0005.rs b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0005.rs new file mode 100644 index 0000000000..074d761c7b --- /dev/null +++ b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0005.rs @@ -0,0 +1,7 @@ +05 +1 + + + +b' + \ No newline at end of file