Skip to content

Commit 1b4a888

Browse files
committed
Create a get_sign_row_props function
1 parent 2a4bf6f commit 1b4a888

1 file changed

Lines changed: 30 additions & 23 deletions

File tree

lua/scrollview.lua

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,30 +1734,15 @@ local show_scrollbar = function(winid, bar_winid)
17341734
return bar_winid
17351735
end
17361736

1737-
-- Show signs for the specified 'winid' window ID. A list of existing sign
1738-
-- winids, 'sign_winids', is specified for possible reuse. Reused windows are
1739-
-- removed from the list. The bar_winid is necessary to correctly position
1740-
-- signs to not intersect the scrollbar.
1741-
local show_signs = function(winid, sign_winids, bar_winid)
1742-
local shown = {} -- a list winids for the signs created
1743-
-- Neovim 0.8 has an issue with matchaddpos highlighting (similar type of
1744-
-- issue reported in Neovim #22906).
1745-
if not to_bool(fn.has('nvim-0.9')) then return shown end
1746-
local bar_props
1747-
-- The scrollbar may not be displayed (e.g., if
1748-
-- scrollview_hide_on_float_intersect is set).
1749-
if bar_winid ~= -1 then
1750-
bar_props = api.nvim_win_get_var(bar_winid, PROPS_VAR)
1751-
end
1737+
-- get_sign_row_props returns a mapping of rows to their filtered list of sign
1738+
-- properties for the specified window.
1739+
-- {[12] = {{name = "scrollview_signs_24_marks", symbol = "c",
1740+
-- lines = {79}, priority = 50, sign_spec_id = 24, ...}, ...}, ...}
1741+
local get_sign_row_props = function(winid, bar_props)
17521742
local cur_winid = api.nvim_get_current_win()
1753-
local wininfo = fn.getwininfo(winid)[1]
1754-
local config = api.nvim_win_get_config(winid)
1755-
local is_float = tbl_get(config, 'relative', '') ~= ''
1756-
if is_restricted(winid) then return shown end
17571743
local bufnr = api.nvim_win_get_buf(winid)
17581744
local line_count = api.nvim_buf_line_count(bufnr)
17591745
local topline_lookup = nil -- only set when needed
1760-
local base_col = calculate_scrollbar_column(winid)
17611746
-- lookup maps rows to a mapping of names to sign properties (with lines).
17621747
-- {[12] = {scrollview_signs_24_marks = {
17631748
-- symbol = {"c"}, lines = {79}, ...}, ...}, ...}
@@ -1848,9 +1833,6 @@ local show_signs = function(winid, sign_winids, bar_winid)
18481833
end
18491834
end
18501835
end
1851-
-- row_props maps rows to their filtered list of sign properties.
1852-
-- {[12] = {{name = "scrollview_signs_24_marks", symbol = "c",
1853-
-- lines = {79}, priority = 50, sign_spec_id = 24, ...}, ...}, ...}
18541836
local row_props = {}
18551837
for row, props_lookup in pairs(lookup) do
18561838
local props_list = {}
@@ -1943,6 +1925,31 @@ local show_signs = function(winid, sign_winids, bar_winid)
19431925
table.insert(row_props[item.row], item.props)
19441926
end
19451927
end
1928+
return row_props
1929+
end
1930+
1931+
-- Show signs for the specified 'winid' window ID. A list of existing sign
1932+
-- winids, 'sign_winids', is specified for possible reuse. Reused windows are
1933+
-- removed from the list. The bar_winid is necessary to correctly position
1934+
-- signs to not intersect the scrollbar.
1935+
local show_signs = function(winid, sign_winids, bar_winid)
1936+
local shown = {} -- a list of winids for the signs created
1937+
-- Neovim 0.8 has an issue with matchaddpos highlighting (similar type of
1938+
-- issue reported in Neovim #22906).
1939+
if not to_bool(fn.has('nvim-0.9')) then return shown end
1940+
local bar_props
1941+
-- The scrollbar may not be displayed (e.g., if
1942+
-- scrollview_hide_on_float_intersect is set).
1943+
if bar_winid ~= -1 then
1944+
bar_props = api.nvim_win_get_var(bar_winid, PROPS_VAR)
1945+
end
1946+
local cur_winid = api.nvim_get_current_win()
1947+
local wininfo = fn.getwininfo(winid)[1]
1948+
local config = api.nvim_win_get_config(winid)
1949+
local is_float = tbl_get(config, 'relative', '') ~= ''
1950+
if is_restricted(winid) then return shown end
1951+
local base_col = calculate_scrollbar_column(winid)
1952+
local row_props = get_sign_row_props(winid, bar_props)
19461953
for row, props_list in pairs(row_props) do
19471954
-- A set of columns, to prevent creating multiple signs in the same
19481955
-- location.

0 commit comments

Comments
 (0)