@@ -174,7 +174,20 @@ impl App {
174174 sender_app,
175175 } ;
176176
177- let tab = env. options . borrow ( ) . current_tab ( ) ;
177+ let mut select_file: Option < PathBuf > = None ;
178+ let tab = if let Some ( file) = cliargs. select_file {
179+ // convert to relative git path
180+ if let Ok ( abs) = file. canonicalize ( ) {
181+ if let Ok ( path) = abs. strip_prefix (
182+ env. repo . borrow ( ) . gitpath ( ) . canonicalize ( ) ?,
183+ ) {
184+ select_file = Some ( Path :: new ( "." ) . join ( path) ) ;
185+ }
186+ }
187+ 2
188+ } else {
189+ env. options . borrow ( ) . current_tab ( )
190+ } ;
178191
179192 let mut app = Self {
180193 input,
@@ -219,7 +232,7 @@ impl App {
219232 status_tab : Status :: new ( & env) ,
220233 stashing_tab : Stashing :: new ( & env) ,
221234 stashlist_tab : StashList :: new ( & env) ,
222- files_tab : FilesTab :: new ( & env) ,
235+ files_tab : FilesTab :: new ( & env, select_file ) ,
223236 tab : 0 ,
224237 queue : env. queue ,
225238 theme : env. theme ,
@@ -232,21 +245,7 @@ impl App {
232245 popup_stack : PopupStack :: default ( ) ,
233246 } ;
234247
235- if let Some ( file) = cliargs. select_file {
236- app. set_tab ( 2 ) ?;
237- // convert to relative git path
238- if let Ok ( abs) = file. canonicalize ( ) {
239- let repo =
240- app. repo . borrow ( ) . gitpath ( ) . canonicalize ( ) ?;
241- if let Ok ( path) = abs. strip_prefix ( repo) {
242- app. queue . push ( InternalEvent :: SelectFile {
243- path : Path :: new ( "." ) . join ( path) ,
244- } ) ;
245- }
246- }
247- } else {
248- app. set_tab ( tab) ?;
249- }
248+ app. set_tab ( tab) ?;
250249
251250 Ok ( app)
252251 }
@@ -787,9 +786,6 @@ impl App {
787786 InternalEvent :: SelectBranch => {
788787 self . select_branch_popup . open ( ) ?;
789788 }
790- InternalEvent :: SelectFile { path } => {
791- self . files_tab . find_file ( & path) ;
792- }
793789 InternalEvent :: ViewSubmodules => {
794790 self . submodule_popup . open ( ) ?;
795791 }
0 commit comments