File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,9 @@ impl Component for ChangesComponent {
361361 keys:: HOME | keys:: SHIFT_UP => {
362362 self . move_selection ( MoveSelection :: Home )
363363 }
364+ keys:: END | keys:: SHIFT_DOWN => {
365+ self . move_selection ( MoveSelection :: End )
366+ }
364367 keys:: MOVE_LEFT => {
365368 self . move_selection ( MoveSelection :: Left )
366369 }
Original file line number Diff line number Diff line change @@ -99,11 +99,9 @@ impl DiffComponent {
9999 self . scroll . saturating_add ( 1 ) ,
100100 ) ;
101101 }
102-
103102 ScrollType :: Up => {
104103 self . scroll = self . scroll . saturating_sub ( 1 ) ;
105104 }
106-
107105 ScrollType :: Home => self . scroll = 0 ,
108106 ScrollType :: End => self . scroll = scroll_max,
109107 }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ pub enum MoveSelection {
1919 Left ,
2020 Right ,
2121 Home ,
22+ End ,
2223}
2324
2425#[ derive( Copy , Clone , Debug ) ]
@@ -73,6 +74,7 @@ impl StatusTree {
7374 self . selection_right ( selection)
7475 }
7576 MoveSelection :: Home => SelectionChange :: new ( 0 , false ) ,
77+ MoveSelection :: End => self . selection_end ( ) ,
7678 } ;
7779
7880 let changed_index =
@@ -162,6 +164,27 @@ impl StatusTree {
162164 SelectionChange :: new ( new_index, false )
163165 }
164166
167+ fn selection_end ( & self ) -> SelectionChange {
168+ let items_max = self . tree . len ( ) . saturating_sub ( 1 ) ;
169+
170+ let mut new_index = items_max;
171+
172+ loop {
173+ if self . is_visible_index ( new_index) {
174+ break ;
175+ }
176+
177+ if new_index == 0 {
178+ break ;
179+ }
180+
181+ new_index = new_index. saturating_sub ( 1 ) ;
182+ new_index = cmp:: min ( new_index, items_max) ;
183+ }
184+
185+ SelectionChange :: new ( new_index, false )
186+ }
187+
165188 fn is_visible_index ( & self , idx : usize ) -> bool {
166189 self . tree [ idx] . info . visible
167190 }
You can’t perform that action at this time.
0 commit comments