diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-11-08 11:37:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-08 11:37:06 +0100 |
commit | ea5e6aa8d713160ae6789053cde8eb1e3f0c5639 (patch) | |
tree | 6bb1bb1ad1f0d2cc239edd369bee505aeefd1a52 /zellij-utils/src/plugin_api/action.rs | |
parent | d4657a2fd138bba418532cc307faa0ca7dcf9b5d (diff) |
fix(ux): LaunchPlugin and some cwd fixes (#2916)
* LaunchPlugin and some cwd fixes
* style(fmt): rustfmt
* fix e2e tests and some cleanups
* fmt
Diffstat (limited to 'zellij-utils/src/plugin_api/action.rs')
-rw-r--r-- | zellij-utils/src/plugin_api/action.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs index 1048d91f6..dc8c29380 100644 --- a/zellij-utils/src/plugin_api/action.rs +++ b/zellij-utils/src/plugin_api/action.rs @@ -413,6 +413,32 @@ impl TryFrom<ProtobufAction> for Action { _ => Err("Wrong payload for Action::LaunchOrFocusPlugin"), } }, + Some(ProtobufActionName::LaunchPlugin) => match protobuf_action.optional_payload { + Some(OptionalPayload::LaunchOrFocusPluginPayload(payload)) => { + let run_plugin_location = + RunPluginLocation::parse(&payload.plugin_url, None) + .map_err(|_| "Malformed LaunchOrFocusPlugin payload")?; + let configuration: PluginUserConfiguration = payload + .plugin_configuration + .and_then(|p| PluginUserConfiguration::try_from(p).ok()) + .unwrap_or_default(); + let run_plugin = RunPlugin { + _allow_exec_host_cmd: false, + location: run_plugin_location, + configuration, + }; + let should_float = payload.should_float; + let _move_to_focused_tab = payload.move_to_focused_tab; // not actually used in + // this action + let should_open_in_place = payload.should_open_in_place; + Ok(Action::LaunchPlugin( + run_plugin, + should_float, + should_open_in_place, + )) + }, + _ => Err("Wrong payload for Action::LaunchOrFocusPlugin"), + }, Some(ProtobufActionName::LeftMouseRelease) => match protobuf_action.optional_payload { Some(OptionalPayload::LeftMouseReleasePayload(payload)) => { let position = payload.try_into()?; @@ -996,6 +1022,21 @@ impl TryFrom<Action> for ProtobufAction { )), }) }, + Action::LaunchPlugin(run_plugin, should_float, should_open_in_place) => { + let url: Url = Url::from(&run_plugin.location); + Ok(ProtobufAction { + name: ProtobufActionName::LaunchPlugin as i32, + optional_payload: Some(OptionalPayload::LaunchOrFocusPluginPayload( + LaunchOrFocusPluginPayload { + plugin_url: url.into(), + should_float, + move_to_focused_tab: false, + should_open_in_place, + plugin_configuration: Some(run_plugin.configuration.try_into()?), + }, + )), + }) + }, Action::LeftMouseRelease(position) => { let position: ProtobufPosition = position.try_into()?; Ok(ProtobufAction { |