From d3c484acea72bfe7129482ac60b26e4f175b58b9 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 26 May 2024 15:45:14 +1000 Subject: [PATCH] refactor(#2731): resolve warnings, type gymnastics --- lua/nvim-tree/actions/tree/find-file.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/nvim-tree/actions/tree/find-file.lua b/lua/nvim-tree/actions/tree/find-file.lua index 610c5349..3ba7b134 100644 --- a/lua/nvim-tree/actions/tree/find-file.lua +++ b/lua/nvim-tree/actions/tree/find-file.lua @@ -24,18 +24,19 @@ function M.fn(opts) local bufnr, path -- (optional) buffer number and path - if type(opts.buf) == "nil" then + local opts_buf = opts.buf + if type(opts_buf) == "nil" then bufnr = vim.api.nvim_get_current_buf() path = vim.api.nvim_buf_get_name(bufnr) - elseif type(opts.buf) == "number" then - if not vim.api.nvim_buf_is_valid(opts.buf) then + elseif type(opts_buf) == "number" then + if not vim.api.nvim_buf_is_valid(opts_buf) then return end - bufnr = tonumber(opts.buf) + bufnr = opts_buf path = vim.api.nvim_buf_get_name(bufnr) - elseif type(opts.buf) == "string" then + elseif type(opts_buf) == "string" then bufnr = nil - path = tostring(opts.buf) + path = tostring(opts_buf) else return end