fix(plugins): various pre-release issues (#3246)
* fix(strider): close_self instead of close_focus * fix(plugins): populate caller_cwd for all aliases * fix(config): launch the session-manager alias rather than the explicit internal url * style(fmt): rustfmt * fix tests
This commit is contained in:
parent
52e81bec7d
commit
462239b535
10 changed files with 68 additions and 51 deletions
|
|
@ -158,7 +158,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.close_on_selection {
|
if self.close_on_selection {
|
||||||
close_focus();
|
close_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn send_filepick_response(&mut self) {
|
pub fn send_filepick_response(&mut self) {
|
||||||
|
|
@ -178,7 +178,7 @@ impl State {
|
||||||
.with_payload(selected_path.display().to_string()),
|
.with_payload(selected_path.display().to_string()),
|
||||||
);
|
);
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
close_focus();
|
close_self();
|
||||||
},
|
},
|
||||||
Some((PipeSource::Cli(pipe_id), _args)) => {
|
Some((PipeSource::Cli(pipe_id), _args)) => {
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
|
|
@ -186,7 +186,7 @@ impl State {
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
unblock_cli_pipe_input(pipe_id);
|
unblock_cli_pipe_input(pipe_id);
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
close_focus();
|
close_self();
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1348,7 +1348,7 @@ impl Pty {
|
||||||
should_float: Option<bool>,
|
should_float: Option<bool>,
|
||||||
should_open_in_place: bool, // should be opened in place
|
should_open_in_place: bool, // should be opened in place
|
||||||
pane_title: Option<String>, // pane title
|
pane_title: Option<String>, // pane title
|
||||||
run: RunPluginOrAlias,
|
mut run: RunPluginOrAlias,
|
||||||
tab_index: usize, // tab index
|
tab_index: usize, // tab index
|
||||||
pane_id_to_replace: Option<PaneId>, // pane id to replace if this is to be opened "in-place"
|
pane_id_to_replace: Option<PaneId>, // pane id to replace if this is to be opened "in-place"
|
||||||
client_id: ClientId,
|
client_id: ClientId,
|
||||||
|
|
@ -1359,7 +1359,7 @@ impl Pty {
|
||||||
// of the pipeline between threads and end up needing to forward this
|
// of the pipeline between threads and end up needing to forward this
|
||||||
_floating_pane_coordinates: Option<FloatingPaneCoordinates>,
|
_floating_pane_coordinates: Option<FloatingPaneCoordinates>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let cwd = cwd.or_else(|| {
|
let get_focused_cwd = || {
|
||||||
self.active_panes
|
self.active_panes
|
||||||
.get(&client_id)
|
.get(&client_id)
|
||||||
.and_then(|pane| match pane {
|
.and_then(|pane| match pane {
|
||||||
|
|
@ -1372,8 +1372,14 @@ impl Pty {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|input| input.get_cwd(Pid::from_raw(id)))
|
.and_then(|input| input.get_cwd(Pid::from_raw(id)))
|
||||||
})
|
})
|
||||||
});
|
};
|
||||||
|
|
||||||
|
let cwd = cwd.or_else(get_focused_cwd);
|
||||||
|
|
||||||
|
if let RunPluginOrAlias::Alias(alias) = &mut run {
|
||||||
|
let cwd = get_focused_cwd();
|
||||||
|
alias.set_caller_cwd_if_not_set(cwd);
|
||||||
|
}
|
||||||
self.bus.senders.send_to_plugin(PluginInstruction::Load(
|
self.bus.senders.send_to_plugin(PluginInstruction::Load(
|
||||||
should_float,
|
should_float,
|
||||||
should_open_in_place,
|
should_open_in_place,
|
||||||
|
|
|
||||||
|
|
@ -3544,7 +3544,7 @@ pub(crate) fn screen_thread_main(
|
||||||
should_float,
|
should_float,
|
||||||
Some(run_plugin),
|
Some(run_plugin),
|
||||||
None,
|
None,
|
||||||
None,
|
Some(client_id),
|
||||||
)
|
)
|
||||||
}, ?);
|
}, ?);
|
||||||
} else if let Some(active_tab) =
|
} else if let Some(active_tab) =
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ keybinds {
|
||||||
bind "Ctrl s" { SwitchToMode "Scroll"; }
|
bind "Ctrl s" { SwitchToMode "Scroll"; }
|
||||||
bind "d" { Detach; }
|
bind "d" { Detach; }
|
||||||
bind "w" {
|
bind "w" {
|
||||||
LaunchOrFocusPlugin "zellij:session-manager" {
|
LaunchOrFocusPlugin "session-manager" {
|
||||||
floating true
|
floating true
|
||||||
move_to_focused_tab true
|
move_to_focused_tab true
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -380,15 +380,13 @@ impl Action {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let mut user_configuration =
|
let mut plugin_alias = PluginAlias::new(
|
||||||
configuration.map(|c| c.inner().clone()).unwrap_or_default();
|
|
||||||
user_configuration
|
|
||||||
.insert("caller_cwd".to_owned(), current_dir.display().to_string());
|
|
||||||
RunPluginOrAlias::Alias(PluginAlias::new(
|
|
||||||
&plugin,
|
&plugin,
|
||||||
&Some(user_configuration),
|
&configuration.map(|c| c.inner().clone()),
|
||||||
alias_cwd,
|
alias_cwd,
|
||||||
))
|
);
|
||||||
|
plugin_alias.set_caller_cwd_if_not_set(Some(current_dir));
|
||||||
|
RunPluginOrAlias::Alias(plugin_alias)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if floating {
|
if floating {
|
||||||
|
|
|
||||||
|
|
@ -456,6 +456,27 @@ impl PluginAlias {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn set_caller_cwd_if_not_set(&mut self, caller_cwd: Option<PathBuf>) {
|
||||||
|
// we do this only for an alias because in all other cases this will be handled by the
|
||||||
|
// "cwd" configuration key above
|
||||||
|
// for an alias we might have cases where the cwd is defined on the alias but we still
|
||||||
|
// want to pass the "caller" cwd for the plugin the alias resolves into (eg. a
|
||||||
|
// filepicker that has access to the whole filesystem but wants to start in a specific
|
||||||
|
// folder)
|
||||||
|
if let Some(caller_cwd) = caller_cwd {
|
||||||
|
if self
|
||||||
|
.configuration
|
||||||
|
.as_ref()
|
||||||
|
.map(|c| c.inner().get("caller_cwd").is_none())
|
||||||
|
.unwrap_or(true)
|
||||||
|
{
|
||||||
|
let configuration = self
|
||||||
|
.configuration
|
||||||
|
.get_or_insert_with(|| PluginUserConfiguration::new(BTreeMap::new()));
|
||||||
|
configuration.insert("caller_cwd", caller_cwd.display().to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::derive_hash_xor_eq)]
|
#[allow(clippy::derive_hash_xor_eq)]
|
||||||
|
|
|
||||||
|
|
@ -2655,18 +2655,16 @@ Config {
|
||||||
'w',
|
'w',
|
||||||
): [
|
): [
|
||||||
LaunchOrFocusPlugin(
|
LaunchOrFocusPlugin(
|
||||||
RunPlugin(
|
Alias(
|
||||||
RunPlugin {
|
PluginAlias {
|
||||||
_allow_exec_host_cmd: false,
|
name: "session-manager",
|
||||||
location: Zellij(
|
configuration: Some(
|
||||||
PluginTag(
|
PluginUserConfiguration(
|
||||||
"session-manager",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
configuration: PluginUserConfiguration(
|
|
||||||
{},
|
{},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
initial_cwd: None,
|
initial_cwd: None,
|
||||||
|
run_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -2655,18 +2655,16 @@ Config {
|
||||||
'w',
|
'w',
|
||||||
): [
|
): [
|
||||||
LaunchOrFocusPlugin(
|
LaunchOrFocusPlugin(
|
||||||
RunPlugin(
|
Alias(
|
||||||
RunPlugin {
|
PluginAlias {
|
||||||
_allow_exec_host_cmd: false,
|
name: "session-manager",
|
||||||
location: Zellij(
|
configuration: Some(
|
||||||
PluginTag(
|
PluginUserConfiguration(
|
||||||
"session-manager",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
configuration: PluginUserConfiguration(
|
|
||||||
{},
|
{},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
initial_cwd: None,
|
initial_cwd: None,
|
||||||
|
run_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -2655,18 +2655,16 @@ Config {
|
||||||
'w',
|
'w',
|
||||||
): [
|
): [
|
||||||
LaunchOrFocusPlugin(
|
LaunchOrFocusPlugin(
|
||||||
RunPlugin(
|
Alias(
|
||||||
RunPlugin {
|
PluginAlias {
|
||||||
_allow_exec_host_cmd: false,
|
name: "session-manager",
|
||||||
location: Zellij(
|
configuration: Some(
|
||||||
PluginTag(
|
PluginUserConfiguration(
|
||||||
"session-manager",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
configuration: PluginUserConfiguration(
|
|
||||||
{},
|
{},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
initial_cwd: None,
|
initial_cwd: None,
|
||||||
|
run_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -2655,18 +2655,16 @@ Config {
|
||||||
'w',
|
'w',
|
||||||
): [
|
): [
|
||||||
LaunchOrFocusPlugin(
|
LaunchOrFocusPlugin(
|
||||||
RunPlugin(
|
Alias(
|
||||||
RunPlugin {
|
PluginAlias {
|
||||||
_allow_exec_host_cmd: false,
|
name: "session-manager",
|
||||||
location: Zellij(
|
configuration: Some(
|
||||||
PluginTag(
|
PluginUserConfiguration(
|
||||||
"session-manager",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
configuration: PluginUserConfiguration(
|
|
||||||
{},
|
{},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
initial_cwd: None,
|
initial_cwd: None,
|
||||||
|
run_plugin: None,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue