1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

mux: match workspace to local window when syncing panes

The logic that figures out whether/how to map remote windows
to the potential local window needs to account for the workspaces
on any given local/remote pair.

In particular, if we are called with a primary window id that
has say "default" as its workspace, we mustn't decide to place
remote tabs from a window whose workspace is not "default"
into that local window, or else we can end up in a weird
state where we have 3 workspaces on the remote, but have
accidentally folded one of them into the `default` workspace
and thus end up thinking that we have one workspace with two
windows and one other workspace, instead of the intended
3 windows each with a distinct workspace.

refs: https://github.com/wez/wezterm/issues/1978
This commit is contained in:
Wez Furlong 2022-05-19 22:45:34 -07:00
parent c8c3b8378a
commit 39bb8b3f39

View File

@ -401,19 +401,43 @@ impl ClientDomain {
let mut window = mux
.get_window_mut(local_window_id)
.expect("no such window!?");
log::debug!("adding tab to existing local window {}", local_window_id);
if window.idx_by_id(tab.tab_id()).is_none() {
window.push(&tab);
}
} else if let Some(local_window_id) = primary_window_id.take() {
inner.record_remote_to_local_window_mapping(remote_window_id, local_window_id);
continue;
}
if let Some(local_window_id) = primary_window_id {
// Verify that the workspace is consistent between the local and remote
// windows
if Some(
mux.get_window(local_window_id)
.expect("primary window to be valid")
.get_workspace(),
) == workspace.as_deref()
{
// Yes! We can use this window
log::debug!("adding {} as tab to {}", remote_window_id, local_window_id);
inner.record_remote_to_local_window_mapping(
remote_window_id,
local_window_id,
);
mux.add_tab_to_window(&tab, local_window_id)?;
} else {
primary_window_id.take();
continue;
}
}
log::debug!(
"making new local window for remote {} in workspace {:?}",
remote_window_id,
workspace
);
let local_window_id = mux.new_empty_window(workspace.take());
inner.record_remote_to_local_window_mapping(remote_window_id, *local_window_id);
mux.add_tab_to_window(&tab, *local_window_id)?;
}
}
}
Ok(())
}