Skip to content

Commit d3c484a

Browse files
committed
refactor(#2731): resolve warnings, type gymnastics
1 parent 08333c2 commit d3c484a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lua/nvim-tree/actions/tree/find-file.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ function M.fn(opts)
2424
local bufnr, path
2525

2626
-- (optional) buffer number and path
27-
if type(opts.buf) == "nil" then
27+
local opts_buf = opts.buf
28+
if type(opts_buf) == "nil" then
2829
bufnr = vim.api.nvim_get_current_buf()
2930
path = vim.api.nvim_buf_get_name(bufnr)
30-
elseif type(opts.buf) == "number" then
31-
if not vim.api.nvim_buf_is_valid(opts.buf) then
31+
elseif type(opts_buf) == "number" then
32+
if not vim.api.nvim_buf_is_valid(opts_buf) then
3233
return
3334
end
34-
bufnr = tonumber(opts.buf)
35+
bufnr = opts_buf
3536
path = vim.api.nvim_buf_get_name(bufnr)
36-
elseif type(opts.buf) == "string" then
37+
elseif type(opts_buf) == "string" then
3738
bufnr = nil
38-
path = tostring(opts.buf)
39+
path = tostring(opts_buf)
3940
else
4041
return
4142
end

0 commit comments

Comments
 (0)