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 {
361
361
keys:: HOME | keys:: SHIFT_UP => {
362
362
self . move_selection ( MoveSelection :: Home )
363
363
}
364
+ keys:: END | keys:: SHIFT_DOWN => {
365
+ self . move_selection ( MoveSelection :: End )
366
+ }
364
367
keys:: MOVE_LEFT => {
365
368
self . move_selection ( MoveSelection :: Left )
366
369
}
Original file line number Diff line number Diff line change @@ -99,11 +99,9 @@ impl DiffComponent {
99
99
self . scroll . saturating_add ( 1 ) ,
100
100
) ;
101
101
}
102
-
103
102
ScrollType :: Up => {
104
103
self . scroll = self . scroll . saturating_sub ( 1 ) ;
105
104
}
106
-
107
105
ScrollType :: Home => self . scroll = 0 ,
108
106
ScrollType :: End => self . scroll = scroll_max,
109
107
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ pub enum MoveSelection {
19
19
Left ,
20
20
Right ,
21
21
Home ,
22
+ End ,
22
23
}
23
24
24
25
#[ derive( Copy , Clone , Debug ) ]
@@ -73,6 +74,7 @@ impl StatusTree {
73
74
self . selection_right ( selection)
74
75
}
75
76
MoveSelection :: Home => SelectionChange :: new ( 0 , false ) ,
77
+ MoveSelection :: End => self . selection_end ( ) ,
76
78
} ;
77
79
78
80
let changed_index =
@@ -162,6 +164,27 @@ impl StatusTree {
162
164
SelectionChange :: new ( new_index, false )
163
165
}
164
166
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
+
165
188
fn is_visible_index ( & self , idx : usize ) -> bool {
166
189
self . tree [ idx] . info . visible
167
190
}
You can’t perform that action at this time.
0 commit comments