aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/picker.rs
diff options
context:
space:
mode:
authorMichael Davis2023-07-25 18:15:36 +0000
committerBlaž Hrastnik2023-07-27 02:50:19 +0000
commit98ef05d768d287fef2eb790e0a8a6e9a72832e00 (patch)
tree856fa79ea0924834f786a22a76ddfbe188301330 /helix-term/src/ui/picker.rs
parentf0b877e2588306882f71eaad45a3f3e604885a34 (diff)
Prefer RopeSlice to &Rope in helix_core::syntax
Pascal and I discussed this and we think it's generally better to take a 'RopeSlice' rather than a '&Rope'. The code block rendering function in the markdown component module is a good example for how this can be useful: we can remove an allocation of a rope and instead directly turn a '&str' into a 'RopeSlice' which is very cheap. A change to prefer 'RopeSlice' to '&Rope' whenever the rope isn't modified would be nice, but it would be a very large diff (around 500+ 500-). Starting off with just the syntax functions seems like a nice middle-ground, and we can remove a Rope allocation because of it. Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
Diffstat (limited to 'helix-term/src/ui/picker.rs')
-rw-r--r--helix-term/src/ui/picker.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 13746cfc..4605e2f1 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -453,9 +453,9 @@ impl<T: Item + 'static> Picker<T> {
let text = doc.text().clone();
let loader = cx.editor.syn_loader.clone();
let job = tokio::task::spawn_blocking(move || {
- let syntax = language_config
- .highlight_config(&loader.scopes())
- .and_then(|highlight_config| Syntax::new(&text, highlight_config, loader));
+ let syntax = language_config.highlight_config(&loader.scopes()).and_then(
+ |highlight_config| Syntax::new(text.slice(..), highlight_config, loader),
+ );
let callback = move |editor: &mut Editor, compositor: &mut Compositor| {
let Some(syntax) = syntax else {
log::info!("highlighting picker item failed");