summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-01-24 14:42:02 +0100
committerqkzk <qu3nt1n@gmail.com>2023-01-24 14:42:02 +0100
commitb8a77cbe8fc945adfe1ba129348d187507e41b10 (patch)
tree5f43d3116c270e077a6dea3b67d6f233637fd4ca /src
parentb68ae5ae8e5b62062b977f17243531746b0bdbde (diff)
FIX: need to move twice after fold. Hacky solution
Diffstat (limited to 'src')
-rw-r--r--src/event_exec.rs18
-rw-r--r--src/preview.rs2
-rw-r--r--src/tab.rs4
-rw-r--r--src/tree.rs3
4 files changed, 11 insertions, 16 deletions
diff --git a/src/event_exec.rs b/src/event_exec.rs
index d41de69..61de4bd 100644
--- a/src/event_exec.rs
+++ b/src/event_exec.rs
@@ -1131,7 +1131,7 @@ impl EventExec {
Mode::Navigate(Navigate::EncryptedDrive) => {
EventExec::event_encrypted_drive_prev(status)
}
- Mode::Tree => EventExec::event_select_prev_sibling(status)?,
+ Mode::Tree => EventExec::event_select_prev(status)?,
Mode::InputCompleted(_) => {
status.selected().completion.prev();
}
@@ -1153,7 +1153,7 @@ impl EventExec {
EventExec::event_encrypted_drive_next(status)
}
Mode::InputCompleted(_) => status.selected().completion.next(),
- Mode::Tree => EventExec::event_select_next_sibling(status)?,
+ Mode::Tree => EventExec::event_select_next(status)?,
_ => (),
};
Ok(())
@@ -1488,7 +1488,7 @@ impl EventExec {
let (tree, _, _) = tab.directory.tree.explore_position(false);
tree.node.toggle_fold();
tab.directory.make_preview(colors);
- Ok(())
+ Self::event_select_next(status)
}
/// Unfold every child node in the tree.
@@ -1531,16 +1531,16 @@ impl EventExec {
status.selected().tree_select_parent(&colors)
}
- /// Select the next sibling of the current node and reset the display.
- pub fn event_select_next_sibling(status: &mut Status) -> FmResult<()> {
+ /// Select the next sibling of the current node.
+ pub fn event_select_next(status: &mut Status) -> FmResult<()> {
let colors = status.config_colors.clone();
- status.selected().tree_select_next_sibling(&colors)
+ status.selected().tree_select_next(&colors)
}
- /// Select the previous sibling of the current node and reset the display.
- pub fn event_select_prev_sibling(status: &mut Status) -> FmResult<()> {
+ /// Select the previous sibling of the current node.
+ pub fn event_select_prev(status: &mut Status) -> FmResult<()> {
let colors = status.config_colors.clone();
- status.selected().tree_select_prev_sibling(&colors)
+ status.selected().tree_select_prev(&colors)
}
/// Select the last leaf of the tree and reset the view.
diff --git a/src/preview.rs b/src/preview.rs
index db6fb9e..f27cb7f 100644
--- a/src/preview.rs
+++ b/src/preview.rs
@@ -583,7 +583,6 @@ impl Directory {
self.selected_index += step;
}
self.tree.position = self.tree.position_from_index(self.selected_index);
- self.tree.unselect_children();
let (_, _, node) = self.tree.select_from_position()?;
self.tree.current_node = node;
let res: usize;
@@ -609,7 +608,6 @@ impl Directory {
"index: {} position {:?}",
self.selected_index, self.tree.position
);
- self.tree.unselect_children();
let (_, _, node) = self.tree.select_from_position()?;
self.tree.current_node = node;
let res: usize;
diff --git a/src/tab.rs b/src/tab.rs
index a6ed366..1aaf13c 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -268,13 +268,13 @@ impl Tab {
}
/// Select the next sibling.
- pub fn tree_select_next_sibling(&mut self, colors: &Colors) -> FmResult<()> {
+ pub fn tree_select_next(&mut self, colors: &Colors) -> FmResult<()> {
self.directory.unselect_children();
self.directory.select_next(colors)
}
/// Select the previous siblging
- pub fn tree_select_prev_sibling(&mut self, colors: &Colors) -> FmResult<()> {
+ pub fn tree_select_prev(&mut self, colors: &Colors) -> FmResult<()> {
self.directory.unselect_children();
self.directory.select_prev(colors)
}
diff --git a/src/tree.rs b/src/tree.rs
index 0afef15..d38594b 100644
--- a/src/tree.rs
+++ b/src/tree.rs
@@ -56,7 +56,6 @@ pub struct Node {
pub folded: bool,
is_dir: bool,
index: Option<usize>,
- pub nb_leaves: usize,
}
impl Node {
@@ -179,7 +178,6 @@ impl Tree {
position: parent_position,
folded: false,
index: None,
- nb_leaves: leaves.len(),
};
let position = vec![0];
let current_node = node.clone();
@@ -216,7 +214,6 @@ impl Tree {
folded: false,
is_dir: false,
index: None,
- nb_leaves: 0,
};
let leaves = vec![];
let position = vec![0];