Skip to content

Commit cc61f74

Browse files
authored
Merge branch 'master' into node-classes-feature-branch-2
2 parents f73db12 + 1c9553a commit cc61f74

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

Diff for: 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

Diff for: lua/nvim-tree/utils.lua

+28
Original file line numberDiff line numberDiff line change
@@ -571,4 +571,32 @@ function M.is_executable(absolute_path)
571571
end
572572
end
573573

574+
---List of all option info/values
575+
---@param opts vim.api.keyset.option passed directly to vim.api.nvim_get_option_info2 and vim.api.nvim_get_option_value
576+
---@param was_set boolean filter was_set
577+
---@return { info: vim.api.keyset.get_option_info, val: any }[]
578+
function M.enumerate_options(opts, was_set)
579+
local res = {}
580+
581+
local infos = vim.tbl_filter(function(info)
582+
if opts.buf and info.scope ~= "buf" then
583+
return false
584+
elseif opts.win and info.scope ~= "win" then
585+
return false
586+
else
587+
return true
588+
end
589+
end, vim.api.nvim_get_all_options_info())
590+
591+
for _, info in vim.spairs(infos) do
592+
local _, info2 = pcall(vim.api.nvim_get_option_info2, info.name, opts)
593+
if not was_set or info2.was_set then
594+
local val = pcall(vim.api.nvim_get_option_value, info.name, opts)
595+
table.insert(res, { info = info2, val = val })
596+
end
597+
end
598+
599+
return res
600+
end
601+
574602
return M

0 commit comments

Comments
 (0)