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-view/src/editor.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-view/src/editor.rs')
-rw-r--r-- | helix-view/src/editor.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 0fa6d67c..68b74cf0 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -50,7 +50,10 @@ use helix_stdx::path::canonicalize; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; -use arc_swap::access::{DynAccess, DynGuard}; +use arc_swap::{ + access::{DynAccess, DynGuard}, + ArcSwap, +}; fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result<Duration, D::Error> where @@ -918,7 +921,7 @@ pub struct Editor { pub debugger_events: SelectAll<UnboundedReceiverStream<dap::Payload>>, pub breakpoints: HashMap<PathBuf, Vec<Breakpoint>>, - pub syn_loader: Arc<syntax::Loader>, + pub syn_loader: Arc<ArcSwap<syntax::Loader>>, pub theme_loader: Arc<theme::Loader>, /// last_theme is used for theme previews. We store the current theme here, /// and if previewing is cancelled, we can return to it. @@ -1029,7 +1032,7 @@ impl Editor { pub fn new( mut area: Rect, theme_loader: Arc<theme::Loader>, - syn_loader: Arc<syntax::Loader>, + syn_loader: Arc<ArcSwap<syntax::Loader>>, config: Arc<dyn DynAccess<Config>>, handlers: Handlers, ) -> Self { @@ -1190,7 +1193,7 @@ impl Editor { } let scopes = theme.scopes(); - self.syn_loader.set_scopes(scopes.to_vec()); + (*self.syn_loader).load().set_scopes(scopes.to_vec()); match preview { ThemeAction::Preview => { |