Skip to content

Commit

Permalink
fix(plugins): reloading plugin after crash (zellij-org#2929)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif authored Nov 11, 2023
1 parent cb46ac0 commit 45fea58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions zellij-server/src/plugins/plugin_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion zellij-server/src/plugins/wasm_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
9 changes: 8 additions & 1 deletion zellij-server/src/ui/loading_indication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct LoadingIndication {
animation_offset: usize,
plugin_name: String,
terminal_emulator_colors: Option<Palette>,
override_previous_error: bool,
}

impl LoadingIndication {
Expand All @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 45fea58

Please sign in to comment.