From 71f899cb5b7753115b2e16ca115b4f376c4b6aee Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 16 Mar 2021 13:45:32 +0900 Subject: syntax: Highlight using ropes, avoiding dumping whole doc to string. --- helix-term/src/ui/editor.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'helix-term/src/ui') 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 } -- cgit v1.2.3-70-g09d2