diff options
author | kyfanc | 2024-02-13 10:58:53 +0000 |
---|---|---|
committer | GitHub | 2024-02-13 10:58:53 +0000 |
commit | fe869e5dc7a8cd6c2c2e3945816bd890956eef3a (patch) | |
tree | ad0b899b482df976caf3cc2f079dc7d0d8a3769f /helix-term/src/ui/markdown.rs | |
parent | 7934ac77143e69068420556b043dde035255340b (diff) |
fix lsp config reload (#9415)
`syn_loader` was replaced rather than interior value being replace,
old value was still being referenced and not updated after `:config-refresh`.
By using `ArcSwap` like for `config`, each `.load()` call will return the most
updated value.
Co-authored-by: kyfan <kyfan@email>
Diffstat (limited to 'helix-term/src/ui/markdown.rs')
-rw-r--r-- | helix-term/src/ui/markdown.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs index 5cf530ad..749d5850 100644 --- a/helix-term/src/ui/markdown.rs +++ b/helix-term/src/ui/markdown.rs @@ -1,4 +1,5 @@ use crate::compositor::{Component, Context}; +use arc_swap::ArcSwap; use tui::{ buffer::Buffer as Surface, text::{Span, Spans, Text}, @@ -31,7 +32,7 @@ pub fn highlighted_code_block<'a>( text: &str, language: &str, theme: Option<&Theme>, - config_loader: Arc<syntax::Loader>, + config_loader: Arc<ArcSwap<syntax::Loader>>, additional_highlight_spans: Option<Vec<(usize, std::ops::Range<usize>)>>, ) -> Text<'a> { let mut spans = Vec::new(); @@ -48,6 +49,7 @@ pub fn highlighted_code_block<'a>( let ropeslice = RopeSlice::from(text); let syntax = config_loader + .load() .language_configuration_for_injection_string(&InjectionLanguageMarker::Name( language.into(), )) @@ -121,7 +123,7 @@ pub fn highlighted_code_block<'a>( pub struct Markdown { contents: String, - config_loader: Arc<syntax::Loader>, + config_loader: Arc<ArcSwap<syntax::Loader>>, } // TODO: pre-render and self reference via Pin @@ -140,7 +142,7 @@ impl Markdown { ]; const INDENT: &'static str = " "; - pub fn new(contents: String, config_loader: Arc<syntax::Loader>) -> Self { + pub fn new(contents: String, config_loader: Arc<ArcSwap<syntax::Loader>>) -> Self { Self { contents, config_loader, |