@@ -155,13 +155,15 @@ impl RevisionFilesComponent {
155
155
}
156
156
}
157
157
158
- fn selection_changed ( & mut self ) {
159
- //TODO: retrieve TreeFile from tree datastructure
160
- if let Some ( file) = self
161
- . tree
158
+ fn selected_file ( & self ) -> Option < String > {
159
+ self . tree
162
160
. selected_file ( )
163
161
. map ( |file| file. full_path_str ( ) . to_string ( ) )
164
- {
162
+ }
163
+
164
+ fn selection_changed ( & mut self ) {
165
+ //TODO: retrieve TreeFile from tree datastructure
166
+ if let Some ( file) = self . selected_file ( ) {
165
167
log:: info!( "selected: {:?}" , file) ;
166
168
let path = Path :: new ( & file) ;
167
169
if let Some ( item) =
@@ -271,6 +273,11 @@ impl Component for RevisionFilesComponent {
271
273
)
272
274
. order ( order:: NAV ) ,
273
275
) ;
276
+ out. push ( CommandInfo :: new (
277
+ strings:: commands:: edit_item ( & self . key_config ) ,
278
+ self . tree . selected_file ( ) . is_some ( ) ,
279
+ true ,
280
+ ) ) ;
274
281
tree_nav_cmds ( & self . tree , & self . key_config , out) ;
275
282
} else {
276
283
self . current_file . commands ( out, force_all) ;
@@ -314,6 +321,16 @@ impl Component for RevisionFilesComponent {
314
321
self . open_finder ( ) ;
315
322
return Ok ( EventState :: Consumed ) ;
316
323
}
324
+ } else if key == self . key_config . keys . edit_file {
325
+ if let Some ( file) = self . selected_file ( ) {
326
+ //Note: switch to status tab so its clear we are
327
+ // not altering a file inside a revision here
328
+ self . queue . push ( InternalEvent :: TabSwitch ) ;
329
+ self . queue . push (
330
+ InternalEvent :: OpenExternalEditor ( Some ( file) ) ,
331
+ ) ;
332
+ return Ok ( EventState :: Consumed ) ;
333
+ }
317
334
} else if !is_tree_focused {
318
335
return self . current_file . event ( event) ;
319
336
}
0 commit comments