@@ -1664,15 +1664,39 @@ impl App { |
| 1664 | 1664 | } |
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | | - // Update selection during drag |
| 1667 | + // Update selection during drag (with auto-scroll when outside bounds) |
| 1668 | 1668 | if self.selection.is_active() && state & 0x100 != 0 { |
| 1669 | | - if let Some(pane) = self.tabs.focused_pane() { |
| 1670 | | - // Convert viewport row to absolute row |
| 1671 | | - let abs_row = pane.terminal.grid().visible_row_to_absolute(row); |
| 1672 | | - self.selection.update(abs_row, col); |
| 1673 | | - } |
| 1674 | 1669 | if let Some(pane) = self.tabs.focused_pane_mut() { |
| 1675 | | - pane.mark_dirty(); |
| 1670 | + let rows = pane.terminal.rows(); |
| 1671 | + let content_height = (rows as f32 * cell_h) as i16; |
| 1672 | + let raw_y = event.event_y - content_offset; |
| 1673 | + |
| 1674 | + // Check if mouse is outside content bounds |
| 1675 | + if raw_y < 0 { |
| 1676 | + // Mouse above content - scroll up into scrollback |
| 1677 | + let scroll_amount = ((-raw_y) as usize / cell_h as usize).max(1).min(5); |
| 1678 | + pane.terminal.scroll_up(scroll_amount); |
| 1679 | + |
| 1680 | + // Update selection to top visible row |
| 1681 | + let abs_row = pane.terminal.grid().visible_row_to_absolute(0); |
| 1682 | + self.selection.update(abs_row, col); |
| 1683 | + pane.mark_dirty(); |
| 1684 | + } else if raw_y > content_height { |
| 1685 | + // Mouse below content - scroll down (toward bottom) |
| 1686 | + let overshoot = (raw_y - content_height) as usize; |
| 1687 | + let scroll_amount = (overshoot / cell_h as usize).max(1).min(5); |
| 1688 | + pane.terminal.scroll_down(scroll_amount); |
| 1689 | + |
| 1690 | + // Update selection to bottom visible row |
| 1691 | + let abs_row = pane.terminal.grid().visible_row_to_absolute(rows.saturating_sub(1)); |
| 1692 | + self.selection.update(abs_row, col); |
| 1693 | + pane.mark_dirty(); |
| 1694 | + } else { |
| 1695 | + // Normal case - mouse within bounds |
| 1696 | + let abs_row = pane.terminal.grid().visible_row_to_absolute(row); |
| 1697 | + self.selection.update(abs_row, col); |
| 1698 | + pane.mark_dirty(); |
| 1699 | + } |
| 1676 | 1700 | } |
| 1677 | 1701 | } |
| 1678 | 1702 | |