Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): reloading plugin after crash #2929

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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