@@ -64,28 +64,32 @@ function M.get_window_context(multi_windows)
64
64
end
65
65
66
66
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
79
90
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
87
92
end
88
-
89
93
end
90
94
end
91
95
0 commit comments