From f797c81155e9b7371b24801efac3fcbd236fc9ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 7 Jan 2018 12:13:01 +0300 Subject: Smart eof for blocks --- src/tree/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/tree/mod.rs') diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 00d33cbc7..3980b23ce 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -73,7 +73,7 @@ impl<'f> Node<'f> { Children { next: self.as_node(self.data().first_child) } } - pub fn SyntaxErrors(&self) -> SyntaxErrors<'f> { + pub fn errors(&self) -> SyntaxErrors<'f> { let pos = self.file.errors.iter().position(|e| e.node == self.idx); let next = pos .map(|i| ErrorIdx(i as u32)) @@ -112,12 +112,13 @@ impl<'f> SyntaxError<'f> { } fn next(&self) -> Option> { - if self.file.errors.len() == self.idx.0 as usize { + let next_idx = self.idx.0 + 1; + if !((next_idx as usize) < self.file.errors.len()) { return None; } let result = SyntaxError { file: self.file, - idx: ErrorIdx(self.idx.0 + 1) + idx: ErrorIdx(next_idx) }; if result.data().node != self.data().node { return None; -- cgit v1.2.3