Skip to content

Commit 146a687

Browse files
committed
refactor(#2787): replace deprecated
1 parent 8cf3e60 commit 146a687

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,27 @@ local function pick_win_id()
8989

9090
if laststatus == 3 then
9191
for _, win_id in ipairs(not_selectable) do
92-
local ok_status, statusline = pcall(vim.api.nvim_win_get_option, win_id, "statusline")
93-
local ok_hl, winhl = pcall(vim.api.nvim_win_get_option, win_id, "winhl")
92+
local ok_status, statusline, ok_hl, winhl
93+
94+
if vim.fn.has "nvim-0.10" == 1 then
95+
ok_status, statusline = pcall(vim.api.nvim_get_option_value, "statusline", { win = win_id })
96+
ok_hl, winhl = pcall(vim.api.nvim_get_option_value, "winhl", { win = win_id })
97+
else
98+
ok_status, statusline = pcall(vim.api.nvim_win_get_option, win_id, "statusline") ---@diagnostic disable-line: deprecated
99+
ok_hl, winhl = pcall(vim.api.nvim_win_get_option, win_id, "winhl") ---@diagnostic disable-line: deprecated
100+
end
94101

95102
win_opts[win_id] = {
96103
statusline = ok_status and statusline or "",
97104
winhl = ok_hl and winhl or "",
98105
}
99106

100107
-- Clear statusline for windows not selectable
101-
vim.api.nvim_win_set_option(win_id, "statusline", " ")
108+
if vim.fn.has "nvim-0.10" == 1 then
109+
vim.api.nvim_set_option_value("statusline", " ", { win = win_id })
110+
else
111+
vim.api.nvim_win_set_option(win_id, "statusline", " ") ---@diagnostic disable-line: deprecated
112+
end
102113
end
103114
end
104115

0 commit comments

Comments
 (0)