From fede1336c0ff0b635388e42944e6c12c14d082ec Mon Sep 17 00:00:00 2001 From: Dominic Gerhauser Date: Tue, 24 Sep 2024 15:51:08 +0200 Subject: [PATCH] fix scrollbar panic --- src/terminal_box.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index ca9711f..c1b432d 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only use alacritty_terminal::{ + grid::Dimensions, index::{Column as TermColumn, Point as TermPoint, Side as TermSide}, selection::{Selection, SelectionType}, term::{cell::Flags, TermMode}, @@ -235,8 +236,10 @@ where && y >= 0.0 && y < buffer_size.1.unwrap_or(0.0) { - let col = x / terminal.size().cell_width; + let mut col = x / terminal.size().cell_width; let row = y / terminal.size().cell_height; + // Fix panic on the left edge of the scroll bar + col = col.min(terminal.size().screen_lines().saturating_sub(1) as f32); let location = terminal .viewport_to_point(TermPoint::new(row as usize, TermColumn(col as usize))); let term = terminal.term.lock();