@@ -175,7 +175,20 @@ impl App {
175175 sender_app,
176176 } ;
177177
178- let tab = env. options . borrow ( ) . current_tab ( ) ;
178+ let mut select_file: Option < PathBuf > = None ;
179+ let tab = if let Some ( file) = cliargs. select_file {
180+ // convert to relative git path
181+ if let Ok ( abs) = file. canonicalize ( ) {
182+ if let Ok ( path) = abs. strip_prefix (
183+ env. repo . borrow ( ) . gitpath ( ) . canonicalize ( ) ?,
184+ ) {
185+ select_file = Some ( Path :: new ( "." ) . join ( path) ) ;
186+ }
187+ }
188+ 2
189+ } else {
190+ env. options . borrow ( ) . current_tab ( )
191+ } ;
179192
180193 let mut app = Self {
181194 input,
@@ -220,7 +233,7 @@ impl App {
220233 status_tab : Status :: new ( & env) ,
221234 stashing_tab : Stashing :: new ( & env) ,
222235 stashlist_tab : StashList :: new ( & env) ,
223- files_tab : FilesTab :: new ( & env) ,
236+ files_tab : FilesTab :: new ( & env, select_file ) ,
224237 goto_line_popup : GotoLinePopup :: new ( & env) ,
225238 tab : 0 ,
226239 queue : env. queue ,
@@ -234,21 +247,7 @@ impl App {
234247 popup_stack : PopupStack :: default ( ) ,
235248 } ;
236249
237- if let Some ( file) = cliargs. select_file {
238- app. set_tab ( 2 ) ?;
239- // convert to relative git path
240- if let Ok ( abs) = file. canonicalize ( ) {
241- let repo =
242- app. repo . borrow ( ) . gitpath ( ) . canonicalize ( ) ?;
243- if let Ok ( path) = abs. strip_prefix ( repo) {
244- app. queue . push ( InternalEvent :: SelectFile {
245- path : Path :: new ( "." ) . join ( path) ,
246- } ) ;
247- }
248- }
249- } else {
250- app. set_tab ( tab) ?;
251- }
250+ app. set_tab ( tab) ?;
252251
253252 Ok ( app)
254253 }
@@ -791,9 +790,6 @@ impl App {
791790 InternalEvent :: SelectBranch => {
792791 self . select_branch_popup . open ( ) ?;
793792 }
794- InternalEvent :: SelectFile { path } => {
795- self . files_tab . find_file ( & path) ;
796- }
797793 InternalEvent :: ViewSubmodules => {
798794 self . submodule_popup . open ( ) ?;
799795 }
0 commit comments