1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

wezterm cli split-pane now respects cwd of source pane

closes: https://github.com/wez/wezterm/issues/766
This commit is contained in:
Wez Furlong 2021-05-09 08:02:35 -07:00
parent f4e9668952
commit 55289013ed
2 changed files with 20 additions and 7 deletions

View File

@ -14,6 +14,7 @@ As features stabilize some brief notes about them will accumulate here.
* Fixed: ssh client would read `/etc/ssh/config` rather than the proper `/etc/ssh/ssh_config`
* x11: support for [VoidSymbol](config/keys.md#voidsymbol) in key assignments. Thanks to [@digitallyserviced](https://github.com/digitallyserviced)! [#759](https://github.com/wez/wezterm/pull/759)
* Fixed: UTF8-encoded-C1 control codes were not always recognized as control codes, and could result in a panic when later attempting to update the line. [#768](https://github.com/wez/wezterm/issues/768)
* Fixed: `wezterm cli split-pane` didn't use the current working dir of the source pane. [#766](https://github.com/wez/wezterm/issues/766)
### 20210502-154244-3f7122cb

View File

@ -607,14 +607,26 @@ async fn split_pane(split: SplitPane, sender: PduSender) -> anyhow::Result<Pdu>
.ok_or_else(|| anyhow!("domain name {} is invalid", name))?,
};
let pane_id = split.pane_id;
let cwd = split.command_dir.or_else(|| {
mux.get_pane(pane_id)
.and_then(|pane| pane.get_current_working_dir())
.map(|url| {
let path = url.path().to_string();
// On Windows the file URI can produce a path like:
// `/C:\Users` which is valid in a file URI, but the leading slash
// is not liked by the windows file APIs, so we strip it off here.
let bytes = path.as_bytes();
if bytes.len() > 2 && bytes[0] == b'/' && bytes[2] == b':' {
path[1..].to_owned()
} else {
path
}
})
});
let pane = domain
.split_pane(
split.command,
split.command_dir,
tab_id,
split.pane_id,
split.direction,
)
.split_pane(split.command, cwd, tab_id, split.pane_id, split.direction)
.await?;
let dims = pane.get_dimensions();
let size = PtySize {