Skip to content

Commit 23db9bb

Browse files
committed
Use nvim_tabpage_list_wins(0) instead of winnr('$')
Fixes #155
1 parent 70e88d7 commit 23db9bb

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ Documentation for issues, along with some workarounds, can be accessed with:
188188
:help scrollview-issues
189189
```
190190

191-
Some of the known issues are regarding scrollbar synchronization, error messages, session
192-
restoration, and scrollbar floating windows being included in the window count returned by
193-
`winnr('$')`.
191+
Some of the known issues are regarding scrollbar synchronization, error messages,
192+
and session restoration.
194193

195194
## License
196195

doc/scrollview.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,8 @@ Other Issues ~
12361236
\ | mksession<bang> <args>
12371237
\ | silent! ScrollViewEnable
12381238
1239-
* Because scrollbars are floating windows, they are included in the window
1240-
count returned by `winnr('$')`.
1239+
* For `nvim<0.12`, scrollview windows are included in the window count returned
1240+
by `winnr('$')`. Neovim PR #34207 addressed the underlying issue.
12411241
+ Workaround 1: Use a Vimscript function that omits external and floating
12421242
windows in the count. >
12431243
function! WindowCount()

lua/scrollview.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ end
349349

350350
local get_scrollview_windows = function()
351351
local result = {}
352-
for winnr = 1, fn.winnr('$') do
353-
local winid = fn.win_getid(winnr)
352+
for _, winid in ipairs(api.nvim_tabpage_list_wins(0)) do
354353
if is_scrollview_window(winid) then
355354
table.insert(result, winid)
356355
end
@@ -366,8 +365,7 @@ local get_floating_windows = function(hidden)
366365
hidden = false
367366
end
368367
local result = {}
369-
for winnr = 1, fn.winnr('$') do
370-
local winid = fn.win_getid(winnr)
368+
for _, winid in ipairs(api.nvim_tabpage_list_wins(0)) do
371369
local config = api.nvim_win_get_config(winid)
372370
local floating = tbl_get(config, 'relative', '') ~= ''
373371
local workspace_win =
@@ -2468,8 +2466,7 @@ local refresh_impl = function()
24682466
end
24692467
end
24702468
local target_wins = {}
2471-
for winnr = 1, fn.winnr('$') do
2472-
local winid = fn.win_getid(winnr)
2469+
for _, winid in ipairs(api.nvim_tabpage_list_wins(0)) do
24732470
table.insert(target_wins, winid)
24742471
end
24752472
-- Execute sign group callbacks. We don't do this when handle_mouse is
@@ -3673,8 +3670,7 @@ end
36733670
-- Returns a list of window IDs that could potentially have signs.
36743671
local get_sign_eligible_windows = function()
36753672
local winids = {}
3676-
for winnr = 1, fn.winnr('$') do
3677-
local winid = fn.win_getid(winnr)
3673+
for _, winid in ipairs(api.nvim_tabpage_list_wins(0)) do
36783674
if should_show(winid) then
36793675
if not is_restricted(winid) then
36803676
table.insert(winids, winid)

0 commit comments

Comments
 (0)