aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpcpthm <[email protected]>2019-03-21 20:29:27 +0000
committerpcpthm <[email protected]>2019-03-21 23:09:11 +0000
commitbf8e7930daa3fb168106534b1cc418f5bc44e8c0 (patch)
treee4dcb3136cedf4df5c56e65f98f6eff0e2256274
parentedbc18516d211c8dbf07539358c7d8aeca24bb30 (diff)
Fix reparsing failure when removing newline
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs7
-rw-r--r--crates/ra_syntax/tests/data/reparse/fuzz-failures/0005.rs7
2 files changed, 14 insertions, 0 deletions
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>(
39 let node = algo::find_covering_node(root, edit.delete); 39 let node = algo::find_covering_node(root, edit.delete);
40 match node.kind() { 40 match node.kind() {
41 WHITESPACE | COMMENT | IDENT | STRING | RAW_STRING => { 41 WHITESPACE | COMMENT | IDENT | STRING | RAW_STRING => {
42 if node.kind() == WHITESPACE || node.kind() == COMMENT {
43 // removing a new line may extends previous token
44 if node.text().to_string()[edit.delete - node.range().start()].contains('\n') {
45 return None;
46 }
47 }
48
42 let text = get_text_after_edit(node, &edit); 49 let text = get_text_after_edit(node, &edit);
43 let tokens = tokenize(&text); 50 let tokens = tokenize(&text);
44 let token = match tokens[..] { 51 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 @@
105
21
3
4
5
6b'
7 \ No newline at end of file