Skip to content

Commit

Permalink
fix(core.itero): preserve indentation on continued items
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Feb 6, 2023
1 parent 5cd04d8 commit 92c31c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/neorg/modules/core/itero/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.on_event = function(event)
end

if not current or current:type() == "document" then
vim.notify("No object to continue! Make sure you're under a list item.")
vim.notify("No object to continue! Make sure you're under an iterable item like a list or heading.")
return
end

Expand All @@ -116,16 +116,18 @@ module.on_event = function(event)

local text_to_repeat = ts.get_node_text(current:named_child(0), event.buffer)

local _, column = current:start()

vim.api.nvim_buf_set_lines(
event.buffer,
cursor_pos + 1,
cursor_pos + 1,
true,
{ text_to_repeat .. (should_append_extension and "( ) " or "") }
{ string.rep(" ", column) .. text_to_repeat .. (should_append_extension and "( ) " or "") }
)
vim.api.nvim_win_set_cursor(
event.window,
{ cursor_pos + 2, text_to_repeat:len() + (should_append_extension and ("( ) "):len() or 0) }
{ cursor_pos + 2, column + text_to_repeat:len() + (should_append_extension and ("( ) "):len() or 0) }
)
end
end
Expand Down

0 comments on commit 92c31c4

Please sign in to comment.