From 53215e6228c300018c1a75f62a3a94fb99823691 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Thu, 24 Oct 2024 08:46:16 +0200 Subject: [PATCH] fix(plugins): make sure to always render on first resize (#3693) * fix(plugins): make sure to always render on first resize * style(fmt): rustfmt * fix tests --- zellij-server/src/plugins/plugin_loader.rs | 8 ++------ zellij-server/src/plugins/unit/plugin_tests.rs | 14 +++++++------- zellij-server/src/plugins/wasm_bridge.rs | 4 +++- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs index 663d2687..7e26b1b5 100644 --- a/zellij-server/src/plugins/plugin_loader.rs +++ b/zellij-server/src/plugins/plugin_loader.rs @@ -693,12 +693,8 @@ impl<'a> PluginLoader<'a> { .try_into() .map_err(|e| anyhow!("Failed to serialize user configuration: {:?}", e))?; let protobuf_bytes = protobuf_plugin_configuration.encode_to_vec(); - wasi_write_object( - plugin.lock().unwrap().store.data(), - &protobuf_bytes, - // &self.plugin.userspace_configuration.inner(), - ) - .with_context(err_context)?; + wasi_write_object(plugin.lock().unwrap().store.data(), &protobuf_bytes) + .with_context(err_context)?; load_function .call(&mut plugin.lock().unwrap().store, ()) .with_context(err_context)?; diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs index 63d88115..38b8448b 100644 --- a/zellij-server/src/plugins/unit/plugin_tests.rs +++ b/zellij-server/src/plugins/unit/plugin_tests.rs @@ -695,7 +695,7 @@ pub fn load_new_plugin_from_hd() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 1, + 2, &PermissionType::ChangeApplicationState, cache_path, plugin_thread_sender, @@ -775,7 +775,7 @@ pub fn load_new_plugin_with_plugin_alias() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 1, + 2, &PermissionType::ChangeApplicationState, cache_path, plugin_thread_sender, @@ -851,7 +851,7 @@ pub fn plugin_workers() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 2, + 3, &PermissionType::ChangeApplicationState, cache_path, plugin_thread_sender, @@ -931,7 +931,7 @@ pub fn plugin_workers_persist_state() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 4, + 5, &PermissionType::ChangeApplicationState, cache_path, plugin_thread_sender, @@ -5952,7 +5952,7 @@ pub fn unblock_input_plugin_command() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 1, + 2, &PermissionType::ReadCliPipes, cache_path, plugin_thread_sender, @@ -6034,7 +6034,7 @@ pub fn block_input_plugin_command() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 1, + 2, &PermissionType::ReadCliPipes, cache_path, plugin_thread_sender, @@ -6207,7 +6207,7 @@ pub fn pipe_message_to_plugin_plugin_command() { received_screen_instructions, ScreenInstruction::PluginBytes, screen_receiver, - 2, + 3, &PermissionType::ReadCliPipes, cache_path, plugin_thread_sender, diff --git a/zellij-server/src/plugins/wasm_bridge.rs b/zellij-server/src/plugins/wasm_bridge.rs index e1529869..36ac744b 100644 --- a/zellij-server/src/plugins/wasm_bridge.rs +++ b/zellij-server/src/plugins/wasm_bridge.rs @@ -615,7 +615,9 @@ impl WasmBridge { running_plugin.rows = new_rows; running_plugin.columns = new_columns; - if old_rows != new_rows || old_columns != new_columns { + // in the below conditional, we check if event_id == 0 so that we'll + // make sure to always render on the first resize event + if old_rows != new_rows || old_columns != new_columns || event_id == 0 { let rendered_bytes = running_plugin .instance .clone()