summaryrefslogtreecommitdiff
path: root/src/source.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/source.rs')
-rw-r--r--src/source.rs16
1 files changed, 4 insertions, 12 deletions
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<F>(&self, range: Range<usize>, 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);
}