Skip to content

Commit 7138c86

Browse files
authored
fix(util): abstract different win config structures (#253)
1 parent 80b67b2 commit 7138c86

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lua/notify/stages/util.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,22 @@ end
142142
function M.slot_after_previous(win, open_windows, direction)
143143
local key = slot_key(direction)
144144
local cmp = is_increasing(direction) and less or greater
145-
local exists, cur_win_conf = pcall(vim.api.nvim_win_get_config, win)
145+
local exists, cur_win_conf = util.get_win_config(win)
146146
if not exists then
147147
return 0
148148
end
149149

150-
local cur_slot = cur_win_conf[key][false]
150+
local cur_slot = cur_win_conf[key]
151151
local win_confs = {}
152152
for _, w in ipairs(open_windows) do
153-
local success, conf = pcall(vim.api.nvim_win_get_config, w)
153+
local success, conf = util.get_win_config(w)
154154
if success then
155155
win_confs[w] = conf
156156
end
157157
end
158158

159159
local preceding_wins = vim.tbl_filter(function(open_win)
160-
return win_confs[open_win] and cmp(win_confs[open_win][key][false], cur_slot)
160+
return win_confs[open_win] and cmp(win_confs[open_win][key], cur_slot)
161161
end, open_windows)
162162

163163
if #preceding_wins == 0 then
@@ -173,7 +173,7 @@ function M.slot_after_previous(win, open_windows, direction)
173173
end
174174

175175
table.sort(preceding_wins, function(a, b)
176-
return cmp(win_confs[a][key][false], win_confs[b][key][false])
176+
return cmp(win_confs[a][key], win_confs[b][key])
177177
end)
178178

179179
local last_win = preceding_wins[#preceding_wins]
@@ -182,13 +182,13 @@ function M.slot_after_previous(win, open_windows, direction)
182182
if is_increasing(direction) then
183183
return move_slot(
184184
direction,
185-
last_win_conf[key][false],
185+
last_win_conf[key],
186186
last_win_conf[space_key(direction)] + border_padding(direction, last_win_conf)
187187
)
188188
else
189189
return move_slot(
190190
direction,
191-
last_win_conf[key][false],
191+
last_win_conf[key],
192192
cur_win_conf[space_key(direction)] + border_padding(direction, cur_win_conf)
193193
)
194194
end

0 commit comments

Comments
 (0)