Skip to content

Commit 5fc8d72

Browse files
author
Stephan Dilly
committed
fix home/end buttons on diff and add home button on file list (#43)
1 parent 5b25aba commit 5fc8d72

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/components/changes.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ impl Component for ChangesComponent {
358358
keys::MOVE_UP => {
359359
self.move_selection(MoveSelection::Up)
360360
}
361+
keys::HOME => {
362+
self.move_selection(MoveSelection::Home)
363+
}
364+
keys::SHIFT_UP => {
365+
self.move_selection(MoveSelection::Home)
366+
}
361367
keys::MOVE_LEFT => {
362368
self.move_selection(MoveSelection::Left)
363369
}

src/components/diff.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,19 @@ impl Component for DiffComponent {
374374
self.scroll(ScrollType::Down);
375375
true
376376
}
377-
KeyCode::End | KeyCode::Down if has_shift => {
377+
KeyCode::Down if has_shift => {
378378
self.scroll(ScrollType::End);
379379
true
380380
}
381-
KeyCode::Home | KeyCode::Up if has_shift => {
381+
KeyCode::End => {
382+
self.scroll(ScrollType::End);
383+
true
384+
}
385+
KeyCode::Up if has_shift => {
386+
self.scroll(ScrollType::Home);
387+
true
388+
}
389+
KeyCode::Home => {
382390
self.scroll(ScrollType::Home);
383391
true
384392
}

src/components/statustree.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ pub enum MoveSelection {
1818
Down,
1919
Left,
2020
Right,
21+
Home,
2122
}
2223

24+
#[derive(Copy, Clone, Debug)]
2325
struct SelectionChange {
2426
new_index: usize,
2527
changes: bool,
@@ -70,13 +72,15 @@ impl StatusTree {
7072
MoveSelection::Right => {
7173
self.selection_right(selection)
7274
}
75+
MoveSelection::Home => SelectionChange::new(0, false),
7376
};
7477

75-
let changed = selection_change.new_index != selection;
78+
let changed_index =
79+
selection_change.new_index != selection;
7680

7781
self.selection = Some(selection_change.new_index);
7882

79-
changed || selection_change.changes
83+
changed_index || selection_change.changes
8084
} else {
8185
false
8286
}

src/keys.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ pub const OPEN_COMMIT: KeyEvent = no_mod(KeyCode::Char('c'));
2727
pub const OPEN_HELP: KeyEvent = no_mod(KeyCode::Char('h'));
2828
pub const MOVE_LEFT: KeyEvent = no_mod(KeyCode::Left);
2929
pub const MOVE_RIGHT: KeyEvent = no_mod(KeyCode::Right);
30+
pub const HOME: KeyEvent = no_mod(KeyCode::Home);
3031
pub const MOVE_UP: KeyEvent = no_mod(KeyCode::Up);
3132
pub const MOVE_DOWN: KeyEvent = no_mod(KeyCode::Down);
33+
pub const SHIFT_UP: KeyEvent =
34+
with_mod(KeyCode::Up, KeyModifiers::SHIFT);
3235
pub const STATUS_STAGE_FILE: KeyEvent = no_mod(KeyCode::Enter);
3336
pub const STATUS_RESET_FILE: KeyEvent =
3437
with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT);

0 commit comments

Comments
 (0)