Skip to content

Commit

Permalink
fix(concealer): buggy debounce logic causing visual artifacts (especi…
Browse files Browse the repository at this point in the history
…ally on the first line of a buffer)
  • Loading branch information
vhyrro committed May 2, 2023
1 parent 160d40f commit 45388fc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1429,9 +1429,8 @@ module.on_event = function(event)
module.private.debounce_counters[event.cursor_position[1] + 1] = module.private.debounce_counters[event.cursor_position[1] + 1]
or 0

local function should_debounce()
return module.private.debounce_counters[event.cursor_position[1] + 1]
>= module.config.public.performance.max_debounce
local function should_debounce(start)
return module.private.debounce_counters[start + 1] >= module.config.public.performance.max_debounce
end

local has_conceal = (
Expand Down Expand Up @@ -1535,7 +1534,9 @@ module.on_event = function(event)
return true
end

if should_debounce() then
module.private.debounce_counters[start + 1] = module.private.debounce_counters[start + 1] or 0

if should_debounce(start) then
return
end

Expand All @@ -1550,8 +1551,7 @@ module.on_event = function(event)
)

if mode ~= "i" then
module.private.debounce_counters[event.cursor_position[1] + 1] = module.private.debounce_counters[event.cursor_position[1] + 1]
+ 1
module.private.debounce_counters[start + 1] = module.private.debounce_counters[start + 1] + 1

schedule(buf, function()
local new_line_count = vim.api.nvim_buf_line_count(buf)
Expand Down Expand Up @@ -1582,7 +1582,7 @@ module.on_event = function(event)
module.public.trigger_code_block_highlights(buf, has_conceal)

vim.schedule(function()
module.private.debounce_counters[event.cursor_position[1] + 1] = module.private.debounce_counters[event.cursor_position[1] + 1]
module.private.debounce_counters[start + 1] = module.private.debounce_counters[start + 1]
- 1
end)
end)
Expand Down Expand Up @@ -1622,7 +1622,7 @@ module.on_event = function(event)
)
end)
elseif event.type == "core.autocommands.events.insertleave" then
if should_debounce() then
if should_debounce(event.cursor_position[1]) then
return
end

Expand Down

0 comments on commit 45388fc

Please sign in to comment.