summaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-19 02:55:42 +0000
committerBlaž Hrastnik2020-09-19 02:58:08 +0000
commitb120515613ba24aff224d093b28d85049c774cad (patch)
tree6bd9d1c5c0abd97c5df390301aa9d67cdf0e4673 /helix-term/src
parent3859f6963dfad2d2d09c979a8e6bb283bc5e2cb3 (diff)
Range based highlight_iter. Only works on limiting the start right now
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/editor.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs
index ed2d3a13..e1288e07 100644
--- a/helix-term/src/editor.rs
+++ b/helix-term/src/editor.rs
@@ -104,13 +104,24 @@ impl Editor {
state.doc().len_lines() - 1,
);
+ let range = {
+ // calculate viewport byte ranges
+ let start = state.doc().line_to_byte(self.first_line.into());
+ let end = state.doc().line_to_byte(last_line)
+ + state.doc().line(last_line).len_bytes();
+
+ start..end
+ };
+
+ // TODO: range doesn't actually restrict source, just highlight range
+
// TODO: cache highlight results
// TODO: only recalculate when state.doc is actually modified
let highlights: Vec<_> = state
.syntax
.as_mut()
.unwrap()
- .highlight_iter(source_code.as_bytes(), None, |_| None)
+ .highlight_iter(source_code.as_bytes(), Some(range), None, |_| None)
.unwrap()
.collect(); // TODO: we collect here to avoid double borrow, fix later