Skip to content

Commit

Permalink
fix: stop syntax processing if a buffer is already closed (#859)
Browse files Browse the repository at this point in the history
Co-authored-by: d-r-a-b <>
  • Loading branch information
d-r-a-b authored May 10, 2023
1 parent 5de014e commit cc2834a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1469,8 +1469,7 @@ module.on_event = function(event)
-- chunk at a set interval and applies the conceals that way to reduce load and improve performance.

-- This points to the current block the user's cursor is in
local block_current =
math.floor((line_count / module.config.public.performance.increment) % event.cursor_position[1])
local block_current = math.floor(event.cursor_position[1] / module.config.public.performance.increment)

local function trigger_conceals_for_block(block)
local line_begin = block == 0 and 0 or block * module.config.public.performance.increment - 1
Expand Down
5 changes: 2 additions & 3 deletions lua/neorg/modules/core/syntax/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ module.on_event = function(event)
-- chunk at a set interval and applies the syntax that way to reduce load and improve performance.

-- This points to the current block the user's cursor is in
local block_current =
math.floor((line_count / module.config.public.performance.increment) % event.cursor_position[1])
local block_current = math.floor(event.cursor_position[1] / module.config.public.performance.increment)

local function trigger_syntax_for_block(block)
local line_begin = block == 0 and 0 or block * module.config.public.performance.increment - 1
Expand All @@ -542,7 +541,7 @@ module.on_event = function(event)
or (block_bottom * module.config.public.performance.increment - 1 >= 0)
local block_top_valid = block_top * module.config.public.performance.increment - 1 < line_count

if not block_bottom_valid and not block_top_valid then
if not vim.api.nvim_buf_is_loaded(buf) or (not block_bottom_valid and not block_top_valid) then
timer:stop()
return
end
Expand Down

0 comments on commit cc2834a

Please sign in to comment.