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

Commit 9be9ffe

Browse files
committed
simplify floating window check
1 parent 81a6427 commit 9be9ffe

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lua/hop/window.lua

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local M = {}
44

55
local function window_context(win_handle, cursor_pos)
66
-- get a bunch of information about the window and the cursor
7-
vim.api.nvim_set_current_win(win_handle) -- 1010
7+
vim.api.nvim_set_current_win(win_handle)
88
local win_info = vim.fn.getwininfo(win_handle)[1]
99
local win_view = vim.fn.winsaveview()
1010
local top_line = win_info.topline - 1
@@ -25,7 +25,7 @@ local function window_context(win_handle, cursor_pos)
2525
end
2626

2727
return {
28-
hwin = win_handle, -- 1010
28+
hwin = win_handle,
2929
cursor_pos = cursor_pos,
3030
top_line = top_line,
3131
bot_line = bot_line,
@@ -51,8 +51,8 @@ function M.get_window_context(multi_windows)
5151
local all_ctxs = {}
5252

5353
-- Generate contexts of windows
54-
local cur_hwin = vim.api.nvim_get_current_win() -- 1010
55-
local cur_hbuf = vim.api.nvim_win_get_buf(cur_hwin) -- 14
54+
local cur_hwin = vim.api.nvim_get_current_win()
55+
local cur_hbuf = vim.api.nvim_win_get_buf(cur_hwin)
5656

5757
all_ctxs[#all_ctxs + 1] = {
5858
hbuf = cur_hbuf, -- 14
@@ -63,11 +63,10 @@ function M.get_window_context(multi_windows)
6363
return all_ctxs
6464
end
6565

66-
-- w == 1010, 1012, 1014, 1080, 1081
6766
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
6867
if vim.api.nvim_win_is_valid(w) then
69-
if vim.api.nvim_win_get_config(w).relative ~= 'win' then -- 1080 or 1081
70-
local b = vim.api.nvim_win_get_buf(w) -- 14
68+
if vim.api.nvim_win_get_config(w).relative == '' then
69+
local b = vim.api.nvim_win_get_buf(w)
7170
if w ~= cur_hwin then
7271

7372
-- check duplicated buffers; the way this is done is by accessing all the already known contexts and checking that

0 commit comments

Comments
 (0)