File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -267,12 +267,6 @@ function M.on_enter(netrw_disabled)
267
267
local stats = vim .loop .fs_stat (bufname )
268
268
local is_dir = stats and stats .type == " directory"
269
269
local is_file = stats and stats .type == " file"
270
- local cwd
271
- if is_dir then
272
- cwd = vim .fn .expand (vim .fn .fnameescape (bufname ))
273
- -- INFO: could potentially conflict with rooter plugins
274
- vim .cmd (" noautocmd cd " .. vim .fn .fnameescape (cwd ))
275
- end
276
270
277
271
local lines = not is_dir and vim .api .nvim_buf_get_lines (bufnr , 0 , - 1 , false ) or {}
278
272
local buf_has_content = # lines > 1 or (# lines == 1 and lines [1 ] ~= " " )
@@ -309,6 +303,13 @@ function M.on_enter(netrw_disabled)
309
303
end
310
304
311
305
if should_open or should_hijack or existing_tree_wins [1 ] ~= nil then
306
+ local cwd
307
+ if is_dir then
308
+ cwd = vim .fn .expand (vim .fn .fnameescape (bufname ))
309
+ -- INFO: could potentially conflict with rooter plugins
310
+ vim .cmd (" noautocmd cd " .. vim .fn .fnameescape (cwd ))
311
+ end
312
+
312
313
lib .open { path = cwd }
313
314
314
315
if should_focus_other_window then
You can’t perform that action at this time.
0 commit comments