aboutsummaryrefslogtreecommitdiff
path: root/src/app/actions.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-07 01:19:39 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-07 01:20:13 +0300
commit17e2b2b878ca9b8cad60fd26baef549479c13081 (patch)
treeafc5947934ee3dd382805952605224de4c77ce13 /src/app/actions.rs
parent4f22e9a73ba4d9029468e078235c5f5ce629d179 (diff)
fix: honor prefix in copy mode
refs #681 Based on PR #1092 by @reobin. Co-authored-by: Robin Gagnon <me@reobin.dev>
Diffstat (limited to 'src/app/actions.rs')
-rw-r--r--src/app/actions.rs32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs
index 52ebbbb7..12c0df87 100644
--- a/src/app/actions.rs
+++ b/src/app/actions.rs
@@ -297,6 +297,14 @@ impl AppState {
}
}
+ fn sync_selection_after_focus_navigation(&mut self) {
+ if self.copy_mode.is_some() {
+ self.sync_copy_mode_with_focus();
+ } else {
+ self.clear_selection();
+ }
+ }
+
pub(crate) fn focus_pane_in_workspace(&mut self, ws_idx: usize, pane_id: PaneId) -> bool {
let Some(ws) = self.workspaces.get(ws_idx) else {
return false;
@@ -313,6 +321,9 @@ impl AppState {
return false;
}
+ if self.copy_mode.is_some() {
+ self.clear_copy_mode_selection();
+ }
self.switch_workspace_tab(ws_idx, tab_idx);
if let Some(tab) = self
.workspaces
@@ -322,6 +333,7 @@ impl AppState {
tab.layout.focus_pane(pane_id);
self.previous_pane_focus = previous;
self.mark_session_dirty();
+ self.sync_copy_mode_with_focus();
return true;
}
false
@@ -949,8 +961,6 @@ impl AppState {
pub fn switch_workspace(&mut self, idx: usize) {
if idx < self.workspaces.len() {
let previous_focus = self.current_pane_focus_target();
- self.selection = None;
- self.selection_autoscroll = None;
self.active = Some(idx);
self.selected = idx;
let workspace_id = self.workspaces[idx].id.clone();
@@ -967,6 +977,7 @@ impl AppState {
self.tab_scroll_follow_active = true;
self.refresh_tab_bar_view();
self.record_pane_focus_after_navigation(previous_focus);
+ self.sync_selection_after_focus_navigation();
}
}
@@ -984,8 +995,6 @@ impl AppState {
let previous_focus = self.current_pane_focus_target();
let workspace_changed = self.active != Some(ws_idx);
- self.selection = None;
- self.selection_autoscroll = None;
self.active = Some(ws_idx);
self.selected = ws_idx;
let workspace_id = self.workspaces[ws_idx].id.clone();
@@ -1003,6 +1012,7 @@ impl AppState {
self.tab_scroll_follow_active = true;
self.refresh_tab_bar_view();
self.record_pane_focus_after_navigation(previous_focus);
+ self.sync_selection_after_focus_navigation();
true
}
@@ -1089,8 +1099,6 @@ impl AppState {
pub fn switch_tab(&mut self, idx: usize) {
if let Some(ws_idx) = self.active {
let previous_focus = self.current_pane_focus_target();
- self.selection = None;
- self.selection_autoscroll = None;
let Some(ws) = self.workspaces.get_mut(ws_idx) else {
return;
};
@@ -1102,6 +1110,7 @@ impl AppState {
self.tab_scroll_follow_active = true;
self.refresh_tab_bar_view();
self.record_pane_focus_after_navigation(previous_focus);
+ self.sync_selection_after_focus_navigation();
}
}
@@ -1429,6 +1438,15 @@ impl AppState {
&mut self,
pane_ids: impl IntoIterator<Item = PaneId>,
) {
+ let pane_ids = pane_ids.into_iter().collect::<Vec<_>>();
+ self.clear_copy_mode_for_removed_panes(pane_ids.iter().copied());
+ if self
+ .previous_pane_focus
+ .as_ref()
+ .is_some_and(|focus| pane_ids.contains(&focus.pane_id))
+ {
+ self.previous_pane_focus = None;
+ }
for pane_id in pane_ids {
self.plugin_panes.remove(&pane_id);
}
@@ -2992,7 +3010,7 @@ impl AppState {
fn handle_pane_died(&mut self, pane_id: PaneId) {
self.pending_agent_notifications.remove(&pane_id);
- self.plugin_panes.remove(&pane_id);
+ self.remove_plugin_pane_records([pane_id]);
let ws_idx = self
.workspaces
.iter()