Skip to content

Commit 4471164

Browse files
author
Matthias Bidlingmeyer
committed
fix(insert_todo): use the new meta return to skip content
1 parent df38874 commit 4471164

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lua/orgmode/org/mappings.lua

+9-8
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,8 @@ function OrgMappings:insert_heading_respect_content(suffix)
731731
if not item then
732732
self:_insert_heading_from_plain_line(suffix)
733733
else
734-
local line = config:respect_blank_before_new_entry({ string.rep('*', item:get_level()) .. ' ' .. suffix })
735-
local end_line = item:get_range().end_line
736-
vim.fn.append(end_line, line)
737-
vim.fn.cursor(end_line + #line, 1)
734+
vim.fn.cursor(item:get_range().start_line, 1)
735+
return self:meta_return(suffix)
738736
end
739737
return vim.cmd([[startinsert!]])
740738
end
@@ -745,13 +743,16 @@ end
745743

746744
function OrgMappings:insert_todo_heading()
747745
local item = self.files:get_closest_headline_or_nil()
748-
local first_todo_keyword = config:get_todo_keywords():first_by_type('TODO')
746+
local first_todo_keyword = config:get_todo_keywords():first_by_type('TODO').value .. ' '
749747
if not item then
750-
self:_insert_heading_from_plain_line(first_todo_keyword.value .. ' ')
748+
self:_insert_heading_from_plain_line(first_todo_keyword)
751749
return vim.cmd([[startinsert!]])
752750
else
753-
vim.fn.cursor(item:get_range().start_line, 1)
754-
return self:meta_return(first_todo_keyword.value .. ' ')
751+
local level = string.rep('*', item:get_level()) .. ' '
752+
local line = config:respect_blank_before_new_entry({ level .. first_todo_keyword })
753+
local start_line = item:get_range().start_line
754+
vim.fn.append(start_line, line)
755+
vim.fn.cursor(start_line + #line, 1)
755756
end
756757
end
757758

0 commit comments

Comments
 (0)