fix: luacheck, buffer override erroring with mark not set
This commit is contained in:
@@ -218,8 +218,7 @@ end
|
|||||||
|
|
||||||
local function is_file_readable(fname)
|
local function is_file_readable(fname)
|
||||||
local stat = luv.fs_stat(fname)
|
local stat = luv.fs_stat(fname)
|
||||||
if not stat or not stat.type == 'file' or not luv.fs_access(fname, 'R') then return false end
|
return stat and stat.type == "file" and luv.fs_access(fname, 'R')
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_base_dir_with_filepath(filepath)
|
local function update_base_dir_with_filepath(filepath)
|
||||||
@@ -238,13 +237,11 @@ function M.find_file(with_open)
|
|||||||
if with_open then
|
if with_open then
|
||||||
M.open()
|
M.open()
|
||||||
view.focus()
|
view.focus()
|
||||||
if not is_file_readable(filepath) then return end
|
|
||||||
update_base_dir_with_filepath(filepath)
|
|
||||||
lib.set_index_and_redraw(filepath)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not is_file_readable(filepath) then return end
|
if not is_file_readable(filepath) then
|
||||||
|
return
|
||||||
|
end
|
||||||
update_base_dir_with_filepath(filepath)
|
update_base_dir_with_filepath(filepath)
|
||||||
lib.set_index_and_redraw(filepath)
|
lib.set_index_and_redraw(filepath)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -189,7 +189,9 @@ function M._prevent_buffer_override()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if a.nvim_buf_is_loaded(M.View.bufnr) and a.nvim_buf_is_valid(M.View.bufnr) then
|
if a.nvim_buf_is_loaded(M.View.bufnr) and a.nvim_buf_is_valid(M.View.bufnr) then
|
||||||
vim.cmd("buffer "..M.View.bufnr)
|
-- pcall necessary to avoid erroring with `mark not set` although no mark are set
|
||||||
|
-- this avoid other issues
|
||||||
|
pcall(vim.api.nvim_win_set_buf, M.get_winnr(), M.View.bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local bufname = a.nvim_buf_get_name(curbuf)
|
local bufname = a.nvim_buf_get_name(curbuf)
|
||||||
|
|||||||
Reference in New Issue
Block a user