Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop syntax processing if a buffer is already closed #859

Merged
merged 2 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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