diff options
Diffstat (limited to 'zellij-server/src/plugins/zellij_exports.rs')
-rw-r--r-- | zellij-server/src/plugins/zellij_exports.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs index 1f65fad54..cc0752ff8 100644 --- a/zellij-server/src/plugins/zellij_exports.rs +++ b/zellij-server/src/plugins/zellij_exports.rs @@ -264,6 +264,7 @@ fn host_run_plugin_command(env: FunctionEnvMut<ForeignFunctionEnv>) { }, PluginCommand::WatchFilesystem => watch_filesystem(env), PluginCommand::DumpSessionLayout => dump_session_layout(env), + PluginCommand::CloseSelf => close_self(env), }, (PermissionStatus::Denied, permission) => { log::error!( @@ -813,6 +814,22 @@ fn show_self(env: &ForeignFunctionEnv, should_float_if_hidden: bool) { apply_action!(action, error_msg, env); } +fn close_self(env: &ForeignFunctionEnv) { + env.plugin_env + .senders + .send_to_screen(ScreenInstruction::ClosePane( + PaneId::Plugin(env.plugin_env.plugin_id), + None, + )) + .with_context(|| format!("failed to close self")) + .non_fatal(); + env.plugin_env + .senders + .send_to_plugin(PluginInstruction::Unload(env.plugin_env.plugin_id)) + .with_context(|| format!("failed to close self")) + .non_fatal(); +} + fn switch_to_mode(env: &ForeignFunctionEnv, input_mode: InputMode) { let action = Action::SwitchToMode(input_mode); let error_msg = || { |