aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-16 04:45:32 +0000
committerBlaž Hrastnik2021-03-16 04:47:06 +0000
commit71f899cb5b7753115b2e16ca115b4f376c4b6aee (patch)
tree657145b2f4985a6ed44576028d7fdc89d3055b90 /helix-term
parent80eca5c32f2a9f3345a2449c8620f86423061d33 (diff)
syntax: Highlight using ropes, avoiding dumping whole doc to string.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index af1d8af8..ff3c70cf 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -75,9 +75,7 @@ impl EditorView {
theme: &Theme,
is_focused: bool,
) {
- // TODO: inefficient, should feed chunks.iter() to tree_sitter.parse_with(|offset, pos|)
let text = view.doc.text();
- let source_code = text.to_string();
let last_line = view.last_line();
@@ -95,7 +93,7 @@ impl EditorView {
let highlights: Vec<_> = match &view.doc.syntax {
Some(syntax) => {
syntax
- .highlight_iter(source_code.as_bytes(), Some(range), None, |_| None)
+ .highlight_iter(text.slice(..), Some(range), None, |_| None)
.unwrap()
.collect() // TODO: we collect here to avoid holding the lock, fix later
}