From bf8e7930daa3fb168106534b1cc418f5bc44e8c0 Mon Sep 17 00:00:00 2001 From: pcpthm Date: Fri, 22 Mar 2019 05:29:27 +0900 Subject: Fix reparsing failure when removing newline --- crates/ra_syntax/src/parsing/reparsing.rs | 7 +++++++ crates/ra_syntax/tests/data/reparse/fuzz-failures/0005.rs | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 crates/ra_syntax/tests/data/reparse/fuzz-failures/0005.rs diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index d54669a95..7e7f914f5 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 000000000..074d761c7 --- /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 -- cgit v1.2.3