Skip to content

Commit

Permalink
Fix subtraction overflows for zero-sized window, slightly questionabl…
Browse files Browse the repository at this point in the history
…e tbh
  • Loading branch information
mgunyho committed Apr 1, 2024
1 parent 0f6e5ab commit 3d6b3b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl TereAppState {
pub fn move_cursor(&mut self, amount: isize, wrap: bool) {
let old_cursor_pos = self.cursor_pos;
let n_visible_items = self.visible_items().len();
let max_cursor_pos = self.main_win_h - 1;
let max_cursor_pos = self.main_win_h.saturating_sub(1);
let old_scroll_pos = self.scroll_pos;

// pointer_pos: the global location of the cursor in ls_output_buf
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'a> TereTui<'a> {

fn redraw_info_window(&mut self) -> IoResult<()> {
let (w, h) = terminal_size_usize()?;
let info_win_row = h - FOOTER_SIZE - INFO_WIN_SIZE;
let info_win_row = h.saturating_sub(FOOTER_SIZE + INFO_WIN_SIZE);

self.queue_clear_row(info_win_row)?;
let mut win = self.window;
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<'a> TereTui<'a> {

fn redraw_footer(&mut self) -> IoResult<()> {
let (w, h) = terminal_size_usize()?;
let footer_win_row = h - FOOTER_SIZE;
let footer_win_row = h.saturating_sub(FOOTER_SIZE);
self.queue_clear_row(footer_win_row)?;

let mut win = self.window;
Expand Down

0 comments on commit 3d6b3b0

Please sign in to comment.