fix(plugins): prevent Strider from opening double-panes when editing files (#2346)
* fix(plugins): make sure to include client_id when writing input * style(fmt): rustfmt * fix(plugins): do not remove client plugins on detach
This commit is contained in:
parent
9d4e60e323
commit
f5a13c7440
3 changed files with 24 additions and 14 deletions
|
|
@ -1664,7 +1664,7 @@ pub(crate) fn screen_thread_main(
|
||||||
client_id,
|
client_id,
|
||||||
|tab: &mut Tab, client_id: ClientId| {
|
|tab: &mut Tab, client_id: ClientId| {
|
||||||
let write_result = match tab.is_sync_panes_active() {
|
let write_result = match tab.is_sync_panes_active() {
|
||||||
true => tab.write_to_terminals_on_current_tab(bytes),
|
true => tab.write_to_terminals_on_current_tab(bytes, client_id),
|
||||||
false => tab.write_to_active_terminal(bytes, client_id),
|
false => tab.write_to_active_terminal(bytes, client_id),
|
||||||
};
|
};
|
||||||
if let Ok(true) = write_result {
|
if let Ok(true) = write_result {
|
||||||
|
|
|
||||||
|
|
@ -1550,7 +1550,7 @@ impl Tab {
|
||||||
let messages_to_pty = terminal_output.drain_messages_to_pty();
|
let messages_to_pty = terminal_output.drain_messages_to_pty();
|
||||||
let clipboard_update = terminal_output.drain_clipboard_update();
|
let clipboard_update = terminal_output.drain_clipboard_update();
|
||||||
for message in messages_to_pty {
|
for message in messages_to_pty {
|
||||||
self.write_to_pane_id(message, PaneId::Terminal(pid))
|
self.write_to_pane_id(message, PaneId::Terminal(pid), None)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
}
|
}
|
||||||
if let Some(string) = clipboard_update {
|
if let Some(string) = clipboard_update {
|
||||||
|
|
@ -1561,14 +1561,18 @@ impl Tab {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_to_terminals_on_current_tab(&mut self, input_bytes: Vec<u8>) -> Result<bool> {
|
pub fn write_to_terminals_on_current_tab(
|
||||||
|
&mut self,
|
||||||
|
input_bytes: Vec<u8>,
|
||||||
|
client_id: ClientId,
|
||||||
|
) -> Result<bool> {
|
||||||
// returns true if a UI update should be triggered (eg. when closing a command pane with
|
// returns true if a UI update should be triggered (eg. when closing a command pane with
|
||||||
// ctrl-c)
|
// ctrl-c)
|
||||||
let mut should_trigger_ui_change = false;
|
let mut should_trigger_ui_change = false;
|
||||||
let pane_ids = self.get_static_and_floating_pane_ids();
|
let pane_ids = self.get_static_and_floating_pane_ids();
|
||||||
for pane_id in pane_ids {
|
for pane_id in pane_ids {
|
||||||
let ui_change_triggered = self
|
let ui_change_triggered = self
|
||||||
.write_to_pane_id(input_bytes.clone(), pane_id)
|
.write_to_pane_id(input_bytes.clone(), pane_id, Some(client_id))
|
||||||
.context("failed to write to terminals on current tab")?;
|
.context("failed to write to terminals on current tab")?;
|
||||||
if ui_change_triggered {
|
if ui_change_triggered {
|
||||||
should_trigger_ui_change = true;
|
should_trigger_ui_change = true;
|
||||||
|
|
@ -1607,7 +1611,7 @@ impl Tab {
|
||||||
.with_context(err_context)?
|
.with_context(err_context)?
|
||||||
};
|
};
|
||||||
// Can't use 'err_context' here since it borrows 'input_bytes'
|
// Can't use 'err_context' here since it borrows 'input_bytes'
|
||||||
self.write_to_pane_id(input_bytes, pane_id)
|
self.write_to_pane_id(input_bytes, pane_id, Some(client_id))
|
||||||
.with_context(|| format!("failed to write to active terminal for client {client_id}"))
|
.with_context(|| format!("failed to write to active terminal for client {client_id}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1615,6 +1619,7 @@ impl Tab {
|
||||||
&mut self,
|
&mut self,
|
||||||
input_bytes: Vec<u8>,
|
input_bytes: Vec<u8>,
|
||||||
position: &Position,
|
position: &Position,
|
||||||
|
client_id: ClientId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let err_context = || format!("failed to write to terminal at position {position:?}");
|
let err_context = || format!("failed to write to terminal at position {position:?}");
|
||||||
|
|
||||||
|
|
@ -1624,7 +1629,7 @@ impl Tab {
|
||||||
.get_pane_id_at(position, false)
|
.get_pane_id_at(position, false)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
if let Some(pane_id) = pane_id {
|
if let Some(pane_id) = pane_id {
|
||||||
self.write_to_pane_id(input_bytes, pane_id)
|
self.write_to_pane_id(input_bytes, pane_id, Some(client_id))
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
@ -1634,14 +1639,19 @@ impl Tab {
|
||||||
.get_pane_id_at(position, false)
|
.get_pane_id_at(position, false)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
if let Some(pane_id) = pane_id {
|
if let Some(pane_id) = pane_id {
|
||||||
self.write_to_pane_id(input_bytes, pane_id)
|
self.write_to_pane_id(input_bytes, pane_id, Some(client_id))
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_to_pane_id(&mut self, input_bytes: Vec<u8>, pane_id: PaneId) -> Result<bool> {
|
pub fn write_to_pane_id(
|
||||||
|
&mut self,
|
||||||
|
input_bytes: Vec<u8>,
|
||||||
|
pane_id: PaneId,
|
||||||
|
client_id: Option<ClientId>,
|
||||||
|
) -> Result<bool> {
|
||||||
// returns true if we need to update the UI (eg. when a command pane is closed with ctrl-c)
|
// returns true if we need to update the UI (eg. when a command pane is closed with ctrl-c)
|
||||||
let err_context = || format!("failed to write to pane with id {pane_id:?}");
|
let err_context = || format!("failed to write to pane with id {pane_id:?}");
|
||||||
|
|
||||||
|
|
@ -1683,7 +1693,7 @@ impl Tab {
|
||||||
PaneId::Plugin(pid) => {
|
PaneId::Plugin(pid) => {
|
||||||
let mut plugin_updates = vec![];
|
let mut plugin_updates = vec![];
|
||||||
for key in parse_keys(&input_bytes) {
|
for key in parse_keys(&input_bytes) {
|
||||||
plugin_updates.push((Some(pid), None, Event::Key(key)));
|
plugin_updates.push((Some(pid), client_id, Event::Key(key)));
|
||||||
}
|
}
|
||||||
self.senders
|
self.senders
|
||||||
.send_to_plugin(PluginInstruction::Update(plugin_updates))
|
.send_to_plugin(PluginInstruction::Update(plugin_updates))
|
||||||
|
|
@ -2592,13 +2602,13 @@ impl Tab {
|
||||||
if let Some(pane) = self.get_pane_at(point, false).with_context(err_context)? {
|
if let Some(pane) = self.get_pane_at(point, false).with_context(err_context)? {
|
||||||
let relative_position = pane.relative_position(point);
|
let relative_position = pane.relative_position(point);
|
||||||
if let Some(mouse_event) = pane.mouse_scroll_up(&relative_position) {
|
if let Some(mouse_event) = pane.mouse_scroll_up(&relative_position) {
|
||||||
self.write_to_terminal_at(mouse_event.into_bytes(), point)
|
self.write_to_terminal_at(mouse_event.into_bytes(), point, client_id)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
} else if pane.is_alternate_mode_active() {
|
} else if pane.is_alternate_mode_active() {
|
||||||
// faux scrolling, send UP n times
|
// faux scrolling, send UP n times
|
||||||
// do n separate writes to make sure the sequence gets adjusted for cursor keys mode
|
// do n separate writes to make sure the sequence gets adjusted for cursor keys mode
|
||||||
for _ in 0..lines {
|
for _ in 0..lines {
|
||||||
self.write_to_terminal_at("\u{1b}[A".as_bytes().to_owned(), point)
|
self.write_to_terminal_at("\u{1b}[A".as_bytes().to_owned(), point, client_id)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2623,13 +2633,13 @@ impl Tab {
|
||||||
if let Some(pane) = self.get_pane_at(point, false).with_context(err_context)? {
|
if let Some(pane) = self.get_pane_at(point, false).with_context(err_context)? {
|
||||||
let relative_position = pane.relative_position(point);
|
let relative_position = pane.relative_position(point);
|
||||||
if let Some(mouse_event) = pane.mouse_scroll_down(&relative_position) {
|
if let Some(mouse_event) = pane.mouse_scroll_down(&relative_position) {
|
||||||
self.write_to_terminal_at(mouse_event.into_bytes(), point)
|
self.write_to_terminal_at(mouse_event.into_bytes(), point, client_id)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
} else if pane.is_alternate_mode_active() {
|
} else if pane.is_alternate_mode_active() {
|
||||||
// faux scrolling, send DOWN n times
|
// faux scrolling, send DOWN n times
|
||||||
// do n separate writes to make sure the sequence gets adjusted for cursor keys mode
|
// do n separate writes to make sure the sequence gets adjusted for cursor keys mode
|
||||||
for _ in 0..lines {
|
for _ in 0..lines {
|
||||||
self.write_to_terminal_at("\u{1b}[B".as_bytes().to_owned(), point)
|
self.write_to_terminal_at("\u{1b}[B".as_bytes().to_owned(), point, client_id)
|
||||||
.with_context(err_context)?;
|
.with_context(err_context)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ fn write_to_suppressed_pane() {
|
||||||
// Make sure it's suppressed now
|
// Make sure it's suppressed now
|
||||||
tab.suppressed_panes.get(&PaneId::Terminal(2)).unwrap();
|
tab.suppressed_panes.get(&PaneId::Terminal(2)).unwrap();
|
||||||
// Write content to it
|
// Write content to it
|
||||||
tab.write_to_pane_id(vec![34, 127, 31, 82, 17, 182], PaneId::Terminal(2))
|
tab.write_to_pane_id(vec![34, 127, 31, 82, 17, 182], PaneId::Terminal(2), None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue