diff options
Diffstat (limited to 'crates/libsyntax2')
-rw-r--r-- | crates/libsyntax2/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/libsyntax2/tests/test/main.rs | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs index d43d26c4c..9ba9970c9 100644 --- a/crates/libsyntax2/src/lib.rs +++ b/crates/libsyntax2/src/lib.rs | |||
@@ -93,7 +93,7 @@ impl File { | |||
93 | &text, &tokens, reparser, | 93 | &text, &tokens, reparser, |
94 | ); | 94 | ); |
95 | let green_root = node.replace_with(green); | 95 | let green_root = node.replace_with(green); |
96 | let errors = merge_errors(self.errors(), new_errors, edit, node.range().start()); | 96 | let errors = merge_errors(self.errors(), new_errors, node, edit); |
97 | Some(File::new(green_root, errors)) | 97 | Some(File::new(green_root, errors)) |
98 | } | 98 | } |
99 | fn full_reparse(&self, edit: &AtomEdit) -> File { | 99 | fn full_reparse(&self, edit: &AtomEdit) -> File { |
@@ -210,14 +210,14 @@ fn is_balanced(tokens: &[Token]) -> bool { | |||
210 | fn merge_errors( | 210 | fn merge_errors( |
211 | old_errors: Vec<SyntaxError>, | 211 | old_errors: Vec<SyntaxError>, |
212 | new_errors: Vec<SyntaxError>, | 212 | new_errors: Vec<SyntaxError>, |
213 | old_node: SyntaxNodeRef, | ||
213 | edit: &AtomEdit, | 214 | edit: &AtomEdit, |
214 | node_offset: TextUnit, | ||
215 | ) -> Vec<SyntaxError> { | 215 | ) -> Vec<SyntaxError> { |
216 | let mut res = Vec::new(); | 216 | let mut res = Vec::new(); |
217 | for e in old_errors { | 217 | for e in old_errors { |
218 | if e.offset < edit.delete.start() { | 218 | if e.offset < old_node.range().start() { |
219 | res.push(e) | 219 | res.push(e) |
220 | } else if e.offset > edit.delete.end() { | 220 | } else if e.offset > old_node.range().end() { |
221 | res.push(SyntaxError { | 221 | res.push(SyntaxError { |
222 | msg: e.msg, | 222 | msg: e.msg, |
223 | offset: e.offset + TextUnit::of_str(&edit.insert) - edit.delete.len(), | 223 | offset: e.offset + TextUnit::of_str(&edit.insert) - edit.delete.len(), |
@@ -227,7 +227,7 @@ fn merge_errors( | |||
227 | for e in new_errors { | 227 | for e in new_errors { |
228 | res.push(SyntaxError { | 228 | res.push(SyntaxError { |
229 | msg: e.msg, | 229 | msg: e.msg, |
230 | offset: e.offset + node_offset, | 230 | offset: e.offset + old_node.range().start(), |
231 | }) | 231 | }) |
232 | } | 232 | } |
233 | res | 233 | res |
diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs index e7ae4d601..596f32216 100644 --- a/crates/libsyntax2/tests/test/main.rs +++ b/crates/libsyntax2/tests/test/main.rs | |||
@@ -59,6 +59,13 @@ struct Foo { | |||
59 | f: foo<|><|> | 59 | f: foo<|><|> |
60 | } | 60 | } |
61 | ", ",\n g: (),"); | 61 | ", ",\n g: (),"); |
62 | do_check(r" | ||
63 | fn foo { | ||
64 | let; | ||
65 | 1 + 1; | ||
66 | <|>92<|>; | ||
67 | } | ||
68 | ", "62"); | ||
62 | } | 69 | } |
63 | 70 | ||
64 | 71 | ||