Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 242322b

Browse files
committed
check if window is valid and not floating before labeling
1 parent 90db1b2 commit 242322b

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

lua/hop/window.lua

+24-20
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,32 @@ function M.get_window_context(multi_windows)
6464
end
6565

6666
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
67-
local b = vim.api.nvim_win_get_buf(w)
68-
if w ~= cur_hwin then
69-
70-
-- check duplicated buffers; the way this is done is by accessing all the already known contexts and checking that
71-
-- the buffer we are accessing is already present in; if it is, we then append the window context to that buffer
72-
local bctx = nil
73-
for _, buffer_ctx in ipairs(all_ctxs) do
74-
if b == buffer_ctx.hbuf then
75-
bctx = buffer_ctx.contexts
76-
break
77-
end
78-
end
67+
if vim.api.nvim_win_is_valid(w) then
68+
if vim.api.nvim_win_get_config(w).relative == '' then
69+
local b = vim.api.nvim_win_get_buf(w)
70+
if w ~= cur_hwin then
71+
72+
-- check duplicated buffers; the way this is done is by accessing all the already known contexts and checking that
73+
-- the buffer we are accessing is already present in; if it is, we then append the window context to that buffer
74+
local bctx = nil
75+
for _, buffer_ctx in ipairs(all_ctxs) do
76+
if b == buffer_ctx.hbuf then
77+
bctx = buffer_ctx.contexts
78+
break
79+
end
80+
end
81+
82+
if bctx then
83+
bctx[#bctx + 1] = window_context(w, vim.api.nvim_win_get_cursor(w))
84+
else
85+
all_ctxs[#all_ctxs + 1] = {
86+
hbuf = b,
87+
contexts = { window_context(w, vim.api.nvim_win_get_cursor(w)) }
88+
}
89+
end
7990

80-
if bctx then
81-
bctx[#bctx + 1] = window_context(w, vim.api.nvim_win_get_cursor(w))
82-
else
83-
all_ctxs[#all_ctxs + 1] = {
84-
hbuf = b,
85-
contexts = { window_context(w, vim.api.nvim_win_get_cursor(w)) }
86-
}
91+
end
8792
end
88-
8993
end
9094
end
9195

0 commit comments

Comments
 (0)