diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 0cdbacfaf59e..51f8c6fb59f3 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -123,36 +123,35 @@ impl EditorView { }; // TODO: range doesn't actually restrict source, just highlight range - let highlights: Vec<_> = match doc.syntax() { - Some(syntax) => { - let scopes = theme.scopes(); - syntax - .highlight_iter(text.slice(..), Some(range), None, |language| { - loader - .language_config_for_scope(&format!("source.{}", language)) - .and_then(|language_config| { - let config = language_config.highlight_config(scopes)?; - let config_ref = { - let reference = config.as_ref(); + let highlights: Vec<_> = + match doc.syntax() { + Some(syntax) => { + let scopes = theme.scopes(); + syntax + .highlight_iter(text.slice(..), Some(range), None, |language| { + loader + .language_config_for_scope(&format!("source.{}", language)) + .and_then(|language_config| { + let config = language_config.highlight_config(scopes)?; + let config_ref = config.as_ref(); // Safe because the referenced `HighglightConfiguration` is behind // an `Arc` that will never be dropped in this function. - unsafe { + let config_ref = unsafe { std::mem::transmute::< _, &'static syntax::HighlightConfiguration, - >(reference) - } - }; - Some(config_ref) - }) - }) - .collect() // TODO: we collect here to avoid holding the lock, fix later - } - None => vec![Ok(HighlightEvent::Source { - start: range.start, - end: range.end, - })], - }; + >(config_ref) + }; + Some(config_ref) + }) + }) + .collect() // TODO: we collect here to avoid holding the lock, fix later + } + None => vec![Ok(HighlightEvent::Source { + start: range.start, + end: range.end, + })], + }; let mut spans = Vec::new(); let mut visual_x = 0u16; let mut line = 0u16;