Skip to content

Commit

Permalink
Pune/India: Don't try to go down as marked items are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 7, 2019
1 parent eae992f commit f9a9cdf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/interactive/app/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl TerminalApp {
Char('d') => self.mark_entry(true),
Char('u') | Backspace | Left => self.exit_node(),
Char('o') | Char('\n') | Right => self.enter_node(),
Ctrl('u') => self.change_entry_selection(CursorDirection::PageUp),
Ctrl('u') => self.change_entry_selection(CursorDirection::PageUp),
Char('k') | Up => self.change_entry_selection(CursorDirection::Up),
Char('j') | Down => self.change_entry_selection(CursorDirection::Down),
Ctrl('d') => self.change_entry_selection(CursorDirection::PageDown),
Expand Down
12 changes: 10 additions & 2 deletions src/interactive/widgets/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,16 @@ impl HelpPane {
{
hotkey("j/<down>", "move down an entry", None);
hotkey("k/<up>", "move up an entry", None);
hotkey("o/<enter>/<right>", "descent into the selected directory", None);
hotkey("u/<left>", "ascent one level into the parent directory", None);
hotkey(
"o/<enter>/<right>",
"descent into the selected directory",
None,
);
hotkey(
"u/<left>",
"ascent one level into the parent directory",
None,
);
hotkey("<backspace>", "^", None);
hotkey("Ctrl + d", "move down 10 entries at once", None);
hotkey("<Page Down>", "^", None);
Expand Down
19 changes: 7 additions & 12 deletions src/interactive/widgets/mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,17 @@ impl MarkPane {

fn remove_selected_and_move_down(&mut self) {
if let Some(selected) = self.selected {
let idx = {
self.marked
.iter()
.sorted_by_key(|(_, v)| &v.index)
.skip(selected)
.map(|(k, _)| k)
.next()
.cloned()
};
if let Some(idx) = idx {
let sorted_entries: Vec<_> = self
.marked
.iter()
.sorted_by_key(|(_, v)| &v.index)
.collect();
if let Some(idx) = sorted_entries.get(selected).map(|(k, _)| *k.to_owned()) {
self.marked.remove(&idx);
self.change_selection(CursorDirection::Down);
}
}
}

fn change_selection(&mut self, direction: CursorDirection) {
self.selected = self.selected.map(|selected| {
direction
Expand Down

0 comments on commit f9a9cdf

Please sign in to comment.