From e5d51d63a3bbb8b46f8a4882c7b476474451d4c8 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Fri, 14 Jan 2022 19:01:56 +0100 Subject: [PATCH] Fix: don't show error if user moves over list edge Ignore this error, as it's common user behavior and an error is distracting. --- src/ui/listview.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/ui/listview.rs b/src/ui/listview.rs index e783529..5014213 100644 --- a/src/ui/listview.rs +++ b/src/ui/listview.rs @@ -463,23 +463,27 @@ impl ViewExt for ListView { let last_idx = self.content.read().unwrap().len().saturating_sub(1); match mode { - MoveMode::Up if self.selected > 0 => { - match amount { - MoveAmount::Extreme => self.move_focus_to(0), - MoveAmount::Integer(amount) => self.move_focus(-(*amount)), + MoveMode::Up => { + if self.selected > 0 { + match amount { + MoveAmount::Extreme => self.move_focus_to(0), + MoveAmount::Integer(amount) => self.move_focus(-(*amount)), + } } return Ok(CommandResult::Consumed(None)); } - MoveMode::Down if self.selected < last_idx => { - match amount { - MoveAmount::Extreme => self.move_focus_to(last_idx), - MoveAmount::Integer(amount) => self.move_focus(*amount), + MoveMode::Down => { + if self.selected < last_idx { + match amount { + MoveAmount::Extreme => self.move_focus_to(last_idx), + MoveAmount::Integer(amount) => self.move_focus(*amount), + } + } + if self.selected == last_idx && self.can_paginate() { + self.pagination.call(&self.content, self.library.clone()); } return Ok(CommandResult::Consumed(None)); } - MoveMode::Down if self.selected == last_idx && self.can_paginate() => { - self.pagination.call(&self.content, self.library.clone()); - } _ => {} } }