Skip to content

Commit 966472e

Browse files
Disable rendering on next listened to event after horizontal scroll
# Details This plugin does not and will not gracefully handle horizontal scrolling. As such add logic to validation to check the left column of the current window attempting to be rendered. If this value is larger than zero rendering will not proceed. We could add an additional event to listen to scroll events, like so: ```lua vim.api.nvim_create_autocmd({ 'WinScrolled' }, { group = group, callback = function() for win, changes in pairs(vim.v.event) do if win ~= 'all' and changes.leftcol ~= 0 then local buf = util.win_to_buf(win) vim.schedule(function() ui.refresh(buf) end) end end end, }) ``` Which would disable and re-enable rendering on horizontal scroll events as appropriate. However listening to every single scroll event seems heavy for this plugin to do, so I would rather avoid it. Maybe make it opt-in, at some point in the future if users want.
1 parent 2263b7d commit 966472e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/render-markdown/ui.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,17 @@ M.clear_valid = function(buf)
5757
return false
5858
end
5959
vim.api.nvim_buf_clear_namespace(buf, M.namespace, 0, -1)
60-
if util.buf_to_win(buf) < 0 then
60+
local win = util.buf_to_win(buf)
61+
if win < 0 then
6162
return false
6263
end
6364
util.set_conceal(buf, state.config.conceal.default)
65+
local leftcol = vim.api.nvim_win_call(win, function()
66+
return vim.fn.winsaveview().leftcol
67+
end)
68+
if leftcol > 0 then
69+
return false
70+
end
6471
return true
6572
end
6673

0 commit comments

Comments
 (0)