@@ -1340,9 +1340,7 @@ end
13401340Actions .openFile = function (state , path , action )
13411341 api .nvim_win_close (state .win , true )
13421342 vim .cmd .stopinsert ()
1343- vim .schedule (function ()
1344- action (path )
1345- end )
1343+ action (path )
13461344end
13471345
13481346Browser .setup = function (state )
@@ -1359,22 +1357,20 @@ Browser.setup = function(state)
13591357 false
13601358 )
13611359 end
1360+ local selected = PathOps .getSelectPath (state )
13621361 local new_path = PathOps .getSelectPath (state )
13631362 if current_buf == state .search_buf then
13641363 new_path = api .nvim_buf_get_lines (0 , 0 , - 1 , false )[1 ]
13651364 end
1366- new_path = vim .fs .normalize (new_path )
1367- if PathOps .isDirectory (new_path ) then
1368- Actions .openDirectory (state , new_path ).run ()
1369- elseif PathOps .isFile (new_path ) then
1370- Actions .openFile (state , new_path , vim .cmd .edit )
1371- elseif
1372- current_buf == state .search_buf
1373- and vim .tbl_isempty (api .nvim_buf_get_lines (state .buf , 0 , - 1 , false ))
1374- then
1365+ if current_buf == state .search_buf and # selected == 0 then
1366+ new_path = vim .fs .normalize (new_path )
13751367 Actions .createAndEdit (state , new_path , vim .cmd .edit ).fork (function (err )
13761368 Notify .err (err )
13771369 end , function () end )
1370+ elseif PathOps .isDirectory (selected ) then
1371+ Actions .openDirectory (state , selected ).run ()
1372+ elseif PathOps .isFile (selected ) then
1373+ Actions .openFile (state , selected , vim .cmd .edit )
13781374 end
13791375 end ,
13801376 buffer = { state .search_buf , state .buf },
0 commit comments