diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-11-11 11:50:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-11 11:50:58 +0100 |
commit | 45fea5817e8febae198e7690a9d41da5f4c48fa2 (patch) | |
tree | c79596627042fc952c4b219017015b02c2619766 | |
parent | cb46ac0b128d23df1c5ac9c8ad4657d067bb3c6b (diff) |
fix(plugins): reloading plugin after crash (#2929)
-rw-r--r-- | zellij-server/src/plugins/plugin_loader.rs | 1 | ||||
-rw-r--r-- | zellij-server/src/plugins/wasm_bridge.rs | 1 | ||||
-rw-r--r-- | zellij-server/src/ui/loading_indication.rs | 9 |
3 files changed, 9 insertions, 2 deletions
diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs index 602b2c4bd..39cb43623 100644 --- a/zellij-server/src/plugins/plugin_loader.rs +++ b/zellij-server/src/plugins/plugin_loader.rs @@ -507,6 +507,7 @@ impl<'a> PluginLoader<'a> { Ok(module) } pub fn compile_module(&mut self) -> Result<Module> { + self.loading_indication.override_previous_error(); display_loading_stage!( indicate_loading_plugin_from_hd_cache_notfound, self.loading_indication, diff --git a/zellij-server/src/plugins/wasm_bridge.rs b/zellij-server/src/plugins/wasm_bridge.rs index 5b7761f1f..bb58d6110 100644 --- a/zellij-server/src/plugins/wasm_bridge.rs +++ b/zellij-server/src/plugins/wasm_bridge.rs @@ -927,5 +927,4 @@ pub fn handle_plugin_crash(plugin_id: PluginId, message: String, senders: Thread plugin_id, loading_indication, )); - let _ = senders.send_to_plugin(PluginInstruction::Unload(plugin_id)); } diff --git a/zellij-server/src/ui/loading_indication.rs b/zellij-server/src/ui/loading_indication.rs index 1aa514ec5..1026c8ae5 100644 --- a/zellij-server/src/ui/loading_indication.rs +++ b/zellij-server/src/ui/loading_indication.rs @@ -25,6 +25,7 @@ pub struct LoadingIndication { animation_offset: usize, plugin_name: String, terminal_emulator_colors: Option<Palette>, + override_previous_error: bool, } impl LoadingIndication { @@ -46,13 +47,16 @@ impl LoadingIndication { let current_animation_offset = self.animation_offset; let current_terminal_emulator_colors = self.terminal_emulator_colors.take(); let mut current_error = self.error.take(); + let override_previous_error = other.override_previous_error; drop(std::mem::replace(self, other)); self.animation_offset = current_animation_offset; self.terminal_emulator_colors = current_terminal_emulator_colors; if let Some(current_error) = current_error.take() { // we do this so that only the first error (usually the root cause) will be shown // when plugins support scrolling, we might want to do an append here - self.error = Some(current_error); + if !override_previous_error { + self.error = Some(current_error); + } } } pub fn indicate_loading_plugin_from_memory(&mut self) { @@ -113,6 +117,9 @@ impl LoadingIndication { pub fn is_error(&self) -> bool { self.error.is_some() } + pub fn override_previous_error(&mut self) { + self.override_previous_error = true; + } fn started_loading(&self) -> bool { self.loading_from_memory.is_some() || self.loading_from_hd_cache.is_some() |