From 7a631d8b09bbffa8c7d90a1038d986876370ea7a Mon Sep 17 00:00:00 2001 From: Martin Haug Date: Tue, 9 Nov 2021 13:07:55 +0100 Subject: Simplify node mode management --- src/source.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/source.rs') diff --git a/src/source.rs b/src/source.rs index 2bba86a9..3117f5b6 100644 --- a/src/source.rs +++ b/src/source.rs @@ -286,22 +286,15 @@ impl SourceFile { .extend(newlines(&self.src[start ..]).map(|idx| start + idx)); // Update the root node. - let insertion_span = Span::new(self.id, replace.start, replace.end); - let source = self.src().to_string(); - if Rc::make_mut(&mut self.root).incremental(&source, insertion_span, with.len()) { + let span = Span::new(self.id, replace.start, replace.end); + if Rc::make_mut(&mut self.root).incremental(&self.src, span, with.len()) { self.was_incremental = true; } else { - self.root = parse(self.src()); + self.root = parse(&self.src); self.was_incremental = false; } } - /// Forces a non-incremental reparsing of the source file. - fn force_reparse(&mut self) { - self.root = parse(self.src()); - self.was_incremental = false; - } - /// Provide highlighting categories for the given range of the source file. pub fn highlight(&self, range: Range, mut f: F) where @@ -499,8 +492,7 @@ mod tests { if incr { assert!(source.was_incremental); let incr_tree = source.root.clone(); - source.force_reparse(); - assert_eq!(source.root, incr_tree); + assert_eq!(parse(source.src()), incr_tree); } else { assert!(!source.was_incremental); } -- cgit v1.2.3