aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs4
-rw-r--r--crates/ra_syntax/src/syntax_error.rs6
-rw-r--r--crates/ra_syntax/tests/data/reparse/fuzz-failures/0000.rs6
3 files changed, 11 insertions, 5 deletions
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index ba77a3b6c..b44cca49d 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -130,11 +130,11 @@ fn merge_errors(
130 if e.offset() <= old_node.range().start() { 130 if e.offset() <= old_node.range().start() {
131 res.push(e) 131 res.push(e)
132 } else if e.offset() >= old_node.range().end() { 132 } else if e.offset() >= old_node.range().end() {
133 res.push(e.add_offset(TextUnit::of_str(&edit.insert) - edit.delete.len())); 133 res.push(e.add_offset(TextUnit::of_str(&edit.insert), edit.delete.len()));
134 } 134 }
135 } 135 }
136 for e in new_errors { 136 for e in new_errors {
137 res.push(e.add_offset(old_node.range().start())); 137 res.push(e.add_offset(old_node.range().start(), 0.into()));
138 } 138 }
139 res 139 res
140} 140}
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs
index bdd431742..4b8c22a57 100644
--- a/crates/ra_syntax/src/syntax_error.rs
+++ b/crates/ra_syntax/src/syntax_error.rs
@@ -48,10 +48,10 @@ impl SyntaxError {
48 } 48 }
49 } 49 }
50 50
51 pub fn add_offset(mut self, plus_offset: TextUnit) -> SyntaxError { 51 pub fn add_offset(mut self, plus_offset: TextUnit, minus_offset: TextUnit) -> SyntaxError {
52 self.location = match self.location { 52 self.location = match self.location {
53 Location::Range(range) => Location::Range(range + plus_offset), 53 Location::Range(range) => Location::Range(range + plus_offset - minus_offset),
54 Location::Offset(offset) => Location::Offset(offset + plus_offset), 54 Location::Offset(offset) => Location::Offset(offset + plus_offset - minus_offset),
55 }; 55 };
56 56
57 self 57 self
diff --git a/crates/ra_syntax/tests/data/reparse/fuzz-failures/0000.rs b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0000.rs
new file mode 100644
index 000000000..388eb74ed
--- /dev/null
+++ b/crates/ra_syntax/tests/data/reparse/fuzz-failures/0000.rs
@@ -0,0 +1,6 @@
10
21
3
4
5
60 \ No newline at end of file