summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-11-06 14:50:04 +0100
committerqkzk <qu3nt1n@gmail.com>2023-11-06 14:50:04 +0100
commit818ffa4aa6ba561fc3f5f56ad09949bca70bfd50 (patch)
treec7add5c83ea3c099dca8502a64558e1a26cca67e /src
parent96eb525c48968251eb56bf5d311d00a19c26b96b (diff)
FIX: move up from to go to last and vice versa
Diffstat (limited to 'src')
-rw-r--r--src/tab.rs6
-rw-r--r--src/tree.rs14
2 files changed, 18 insertions, 2 deletions
diff --git a/src/tab.rs b/src/tab.rs
index db5c08c..e1600a0 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -349,6 +349,9 @@ impl Tab {
pub fn tree_page_down(&mut self) -> Result<()> {
for _ in 1..10 {
self.tree.select_next()?;
+ if self.tree.is_on_last() {
+ break;
+ }
}
Ok(())
}
@@ -357,6 +360,9 @@ impl Tab {
pub fn tree_page_up(&mut self) -> Result<()> {
for _ in 1..10 {
self.tree.select_prev();
+ if self.tree.is_on_root() {
+ break;
+ }
}
Ok(())
}
diff --git a/src/tree.rs b/src/tree.rs
index 2491314..253e102 100644
--- a/src/tree.rs
+++ b/src/tree.rs
@@ -193,9 +193,16 @@ impl Tree {
self.selected == self.root_path
}
+ pub fn is_on_last(&self) -> bool {
+ self.selected == self.last_path
+ }
+
/// Select next sibling or the next sibling of the parent
pub fn select_next(&mut self) -> Result<()> {
- log::info!("select_next START {sel}", sel = self.selected.display());
+ if self.is_on_last() {
+ self.select_root();
+ return Ok(());
+ }
if let Some(next_path) = self.find_next_path() {
let Some(next_node) = self.nodes.get_mut(&next_path) else {
@@ -265,7 +272,10 @@ impl Tree {
// TODO! find the bottom child of parent instead of jumping back 1 level
/// Select previous sibling or the parent
pub fn select_prev(&mut self) {
- log::info!("select_prev START {sel}", sel = self.selected.display());
+ if self.is_on_root() {
+ self.select_last();
+ return;
+ }
if let Some(previous_path) = self.find_prev_path() {
let Some(previous_node) = self.nodes.get_mut(&previous_path) else {