diff --git a/src/core/engine/terminal_ops.rs b/src/core/engine/terminal_ops.rs index fa3df7fc..57a0b30b 100644 --- a/src/core/engine/terminal_ops.rs +++ b/src/core/engine/terminal_ops.rs @@ -208,6 +208,25 @@ impl Engine { Some(zone) } + /// Handle a content click on a non-split terminal pane. Focuses the + /// terminal, resets scrollback, and starts a zero-length selection + /// at `(col, row)` (0-based cells within the pane). Backends call + /// this when there is no `TerminalSplitLayout` cached — in the split + /// case, [`Self::handle_terminal_split_click`] delegates here after + /// setting the active pane (#429). + pub fn handle_terminal_pane_click(&mut self, col: u16, row: u16) { + self.terminal_has_focus = true; + self.terminal_scroll_reset(); + if let Some(term) = self.active_terminal_mut() { + term.selection = Some(crate::core::terminal::TermSelection { + start_row: row, + start_col: col, + end_row: row, + end_col: col, + }); + } + } + /// Handle a click on the terminal content area using a /// `TerminalSplitHit` from the cached layout. Sets pane focus, /// starts selection, or signals a divider drag. Returns `true` if @@ -219,28 +238,12 @@ impl Engine { TerminalSplitHit::Divider => true, TerminalSplitHit::LeftPane { col, row } => { self.terminal_active = 0; - self.terminal_scroll_reset(); - if let Some(term) = self.active_terminal_mut() { - term.selection = Some(crate::core::terminal::TermSelection { - start_row: row, - start_col: col, - end_row: row, - end_col: col, - }); - } + self.handle_terminal_pane_click(col, row); false } TerminalSplitHit::RightPane { col, row } => { self.terminal_active = 1; - self.terminal_scroll_reset(); - if let Some(term) = self.active_terminal_mut() { - term.selection = Some(crate::core::terminal::TermSelection { - start_row: row, - start_col: col, - end_row: row, - end_col: col, - }); - } + self.handle_terminal_pane_click(col, row); false } TerminalSplitHit::Scrollbar | TerminalSplitHit::Outside => false, diff --git a/src/tui_main/mouse.rs b/src/tui_main/mouse.rs index 80b924fb..12a9cf42 100644 --- a/src/tui_main/mouse.rs +++ b/src/tui_main/mouse.rs @@ -2068,17 +2068,11 @@ pub(super) fn handle_mouse( } } else { drop(split_layout); - engine.terminal_has_focus = true; + // #429: focus + scroll reset + selection are now owned by + // the engine. TUI still does the col conversion (panel + // is offset by sidebar/activity-bar width on the left). let term_col = col.saturating_sub(editor_left); - engine.terminal_scroll_reset(); - if let Some(term) = engine.active_terminal_mut() { - term.selection = Some(crate::core::terminal::TermSelection { - start_row: row_offset, - start_col: term_col, - end_row: row_offset, - end_col: term_col, - }); - } + engine.handle_terminal_pane_click(term_col, row_offset); } } return sidebar_width;