Skip to content

Commit

Permalink
fix(concealer): record cursor upon init to fix first line conceal (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom committed Jun 1, 2023
1 parent 729e7ac commit 44ee0cb
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,23 @@ local function clear_all_extmarks(bufid)
vim.api.nvim_buf_clear_namespace(bufid, ns_prettify_flag, 0, -1)
end
local function get_table_default_empty(tbl, key)
if not tbl[key] then
tbl[key] = {}
end
return tbl[key]
end
local function update_cursor(event)
local cursor_record = get_table_default_empty(module.private.cursor_record, event.buffer)
cursor_record.row_0b = event.cursor_position[1] - 1
cursor_record.col_0b = event.cursor_position[2]
cursor_record.line_content = event.line_content
end
local function handle_init_event(event)
assert(vim.api.nvim_win_is_valid(event.window))
update_cursor(event)
local function on_line_callback(
tag,
Expand Down Expand Up @@ -1198,20 +1213,6 @@ local function is_same_line_movement(event)
)
end
local function get_table_default_empty(tbl, key)
if not tbl[key] then
tbl[key] = {}
end
return tbl[key]
end
local function update_cursor(event)
local cursor_record = get_table_default_empty(module.private.cursor_record, event.buffer)
cursor_record.row_0b = event.cursor_position[1] - 1
cursor_record.col_0b = event.cursor_position[2]
cursor_record.line_content = event.line_content
end
local function handle_cursor_moved(event)
-- reveal/conceal when conceallevel>0
-- also triggered when dd / u
Expand Down

0 comments on commit 44ee0cb

Please sign in to comment.