diff options
-rw-r--r-- | crates/ra_syntax/src/parsing/reparsing.rs | 11 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/reparse/fuzz-failures/0001.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/reparse/fuzz-failures/0002.rs | 4 |
3 files changed, 17 insertions, 2 deletions
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( | |||
33 | } | 33 | } |
34 | 34 | ||
35 | fn reparse_leaf<'node>( | 35 | fn reparse_leaf<'node>( |
36 | node: &'node SyntaxNode, | 36 | root: &'node SyntaxNode, |
37 | edit: &AtomTextEdit, | 37 | edit: &AtomTextEdit, |
38 | ) -> Option<(&'node SyntaxNode, GreenNode, Vec<SyntaxError>)> { | 38 | ) -> Option<(&'node SyntaxNode, GreenNode, Vec<SyntaxError>)> { |
39 | let node = algo::find_covering_node(node, 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 | let text = get_text_after_edit(node, &edit); | 42 | let text = get_text_after_edit(node, &edit); |
@@ -50,6 +50,13 @@ fn reparse_leaf<'node>( | |||
50 | return None; | 50 | return None; |
51 | } | 51 | } |
52 | 52 | ||
53 | if let Some(next_char) = root.text().char_at(node.range().end()) { | ||
54 | let tokens_with_next_char = tokenize(&format!("{}{}", text, next_char)); | ||
55 | if tokens_with_next_char.len() == 1 { | ||
56 | return None; | ||
57 | } | ||
58 | } | ||
59 | |||
53 | let green = GreenNode::new_leaf(node.kind(), text.into()); | 60 | let green = GreenNode::new_leaf(node.kind(), text.into()); |
54 | let new_errors = vec![]; | 61 | let new_errors = vec![]; |
55 | Some((node, green, new_errors)) | 62 | Some((node, green, new_errors)) |
diff --git a/crates/ra_syntax/tests/data/reparse/fuzz-failures/0001.rs b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0001.rs new file mode 100644 index 000000000..d2d42c6f9 --- /dev/null +++ b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0001.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | 0 | ||
2 | 1 | ||
3 | |||
4 | bb" \ No newline at end of file | ||
diff --git a/crates/ra_syntax/tests/data/reparse/fuzz-failures/0002.rs b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0002.rs new file mode 100644 index 000000000..3fbee1548 --- /dev/null +++ b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0002.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | 1 | ||
2 | 1 | ||
3 | |||
4 | ""! \ No newline at end of file | ||