Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions src/core/engine/terminal_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
14 changes: 4 additions & 10 deletions src/tui_main/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down