mux: add kill_pane rpc call
This is especially important now that exit_behavior can keep empty panes around in unexpected circumstances.
This commit is contained in:
1 parent
b48f7f6c6a
commit
a3a07c8da5
4 files changed
+41
No files matched your search
@@ -434,6 +434,7 @@ pdu! {
|
||||
SearchScrollbackResponse: 32,
|
||||
SetPaneZoomed: 33,
|
||||
SplitPane: 34,
|
||||
KillPane: 35,
|
||||
}
|
||||
|
||||
impl Pdu {
|
||||
@@ -577,6 +578,11 @@ pub struct SplitPane {
|
||||
pub domain: config::keyassignment::SpawnTabDomain,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
pub struct KillPane {
|
||||
pub pane_id: PaneId,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
pub struct SpawnResponse {
|
||||
pub tab_id: TabId,
|
||||
|
||||
@@ -952,4 +952,5 @@ impl Client {
|
||||
SearchScrollbackRequest,
|
||||
SearchScrollbackResponse
|
||||
);
|
||||
rpc!(kill_pane, KillPane, UnitResponse);
|
||||
}
|
||||
@@ -294,6 +294,20 @@ impl Pane for ClientPane {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn kill(&self) {
|
||||
let client = Arc::clone(&self.client);
|
||||
let remote_pane_id = self.remote_pane_id;
|
||||
promise::spawn::spawn(async move {
|
||||
client
|
||||
.client
|
||||
.kill_pane(KillPane {
|
||||
pane_id: remote_pane_id,
|
||||
})
|
||||
.await
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
fn mouse_event(&self, event: MouseEvent) -> anyhow::Result<()> {
|
||||
self.mouse.borrow_mut().append(event);
|
||||
if MouseState::next(Rc::clone(&self.mouse)) {
|
||||
|
||||
@@ -250,6 +250,26 @@ impl SessionHandler {
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
Pdu::KillPane(KillPane { pane_id }) => {
|
||||
let sender = self.to_write_tx.clone();
|
||||
let per_pane = self.per_pane(pane_id);
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
pane.kill();
|
||||
mux.remove_pane(pane_id);
|
||||
maybe_push_pane_changes(&pane, sender, per_pane)?;
|
||||
Ok(Pdu::UnitResponse(UnitResponse {}))
|
||||
},
|
||||
send_response,
|
||||
);
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
Pdu::SendPaste(SendPaste { pane_id, data }) => {
|
||||
let sender = self.to_write_tx.clone();
|
||||
let per_pane = self.per_pane(pane_id);
|
||||
|
||||
Reference in new issue
Block a user