Skip to content

Commit 1c9553a

Browse files
authored
fix(#2951): highlights incorrect following cancelled pick (#2952)
1 parent ca0904e commit 1c9553a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ local function pick_win_id()
7575
end
7676

7777
local i = 1
78-
local win_opts = {}
78+
local win_opts_selectable = {}
79+
local win_opts_unselectable = {}
7980
local win_map = {}
8081
local laststatus = vim.o.laststatus
8182
vim.o.laststatus = 2
@@ -89,19 +90,16 @@ local function pick_win_id()
8990

9091
if laststatus == 3 then
9192
for _, win_id in ipairs(not_selectable) do
92-
local ok_status, statusline, ok_hl, winhl
93+
local ok_status, statusline
9394

9495
if vim.fn.has("nvim-0.10") == 1 then
9596
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 })
9797
else
9898
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
10099
end
101100

102-
win_opts[win_id] = {
101+
win_opts_unselectable[win_id] = {
103102
statusline = ok_status and statusline or "",
104-
winhl = ok_hl and winhl or "",
105103
}
106104

107105
-- Clear statusline for windows not selectable
@@ -126,7 +124,7 @@ local function pick_win_id()
126124
ok_hl, winhl = pcall(vim.api.nvim_win_get_option, id, "winhl") ---@diagnostic disable-line: deprecated
127125
end
128126

129-
win_opts[id] = {
127+
win_opts_selectable[id] = {
130128
statusline = ok_status and statusline or "",
131129
winhl = ok_hl and winhl or "",
132130
}
@@ -156,7 +154,7 @@ local function pick_win_id()
156154

157155
-- Restore window options
158156
for _, id in ipairs(selectable) do
159-
for opt, value in pairs(win_opts[id]) do
157+
for opt, value in pairs(win_opts_selectable[id]) do
160158
if vim.fn.has("nvim-0.10") == 1 then
161159
vim.api.nvim_set_option_value(opt, value, { win = id })
162160
else
@@ -169,7 +167,7 @@ local function pick_win_id()
169167
for _, id in ipairs(not_selectable) do
170168
-- Ensure window still exists at this point
171169
if vim.api.nvim_win_is_valid(id) then
172-
for opt, value in pairs(win_opts[id]) do
170+
for opt, value in pairs(win_opts_unselectable[id]) do
173171
if vim.fn.has("nvim-0.10") == 1 then
174172
vim.api.nvim_set_option_value(opt, value, { win = id })
175173
else

0 commit comments

Comments
 (0)