File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 218
218
219
219
local function is_file_readable (fname )
220
220
local stat = luv .fs_stat (fname )
221
- if not stat or not stat .type == ' file' or not luv .fs_access (fname , ' R' ) then return false end
222
- return true
221
+ return stat and stat .type == " file" and luv .fs_access (fname , ' R' )
223
222
end
224
223
225
224
local function update_base_dir_with_filepath (filepath )
@@ -238,13 +237,11 @@ function M.find_file(with_open)
238
237
if with_open then
239
238
M .open ()
240
239
view .focus ()
241
- if not is_file_readable (filepath ) then return end
242
- update_base_dir_with_filepath (filepath )
243
- lib .set_index_and_redraw (filepath )
244
- return
245
240
end
246
241
247
- if not is_file_readable (filepath ) then return end
242
+ if not is_file_readable (filepath ) then
243
+ return
244
+ end
248
245
update_base_dir_with_filepath (filepath )
249
246
lib .set_index_and_redraw (filepath )
250
247
end
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ function M.setup()
137
137
vim .cmd " au BufWinEnter,BufWinLeave * lua require'nvim-tree.view'._prevent_buffer_override()"
138
138
vim .cmd " au BufEnter,BufNewFile * lua require'nvim-tree'.open_on_directory()"
139
139
vim .cmd " augroup END"
140
-
140
+
141
141
if vim .g .nvim_tree_disable_keybindings == 1 then
142
142
return
143
143
end
@@ -189,7 +189,9 @@ function M._prevent_buffer_override()
189
189
end
190
190
191
191
if a .nvim_buf_is_loaded (M .View .bufnr ) and a .nvim_buf_is_valid (M .View .bufnr ) then
192
- vim .cmd (" buffer " .. M .View .bufnr )
192
+ -- pcall necessary to avoid erroring with `mark not set` although no mark are set
193
+ -- this avoid other issues
194
+ pcall (vim .api .nvim_win_set_buf , M .get_winnr (), M .View .bufnr )
193
195
end
194
196
195
197
local bufname = a .nvim_buf_get_name (curbuf )
You can’t perform that action at this time.
0 commit comments