Skip to content

Commit

Permalink
fix(insert_todo): use the new meta return to skip content
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Bidlingmeyer committed Oct 28, 2024
1 parent df38874 commit 4471164
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lua/orgmode/org/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,8 @@ function OrgMappings:insert_heading_respect_content(suffix)
if not item then
self:_insert_heading_from_plain_line(suffix)
else
local line = config:respect_blank_before_new_entry({ string.rep('*', item:get_level()) .. ' ' .. suffix })
local end_line = item:get_range().end_line
vim.fn.append(end_line, line)
vim.fn.cursor(end_line + #line, 1)
vim.fn.cursor(item:get_range().start_line, 1)
return self:meta_return(suffix)
end
return vim.cmd([[startinsert!]])
end
Expand All @@ -745,13 +743,16 @@ end

function OrgMappings:insert_todo_heading()
local item = self.files:get_closest_headline_or_nil()
local first_todo_keyword = config:get_todo_keywords():first_by_type('TODO')
local first_todo_keyword = config:get_todo_keywords():first_by_type('TODO').value .. ' '
if not item then
self:_insert_heading_from_plain_line(first_todo_keyword.value .. ' ')
self:_insert_heading_from_plain_line(first_todo_keyword)
return vim.cmd([[startinsert!]])
else
vim.fn.cursor(item:get_range().start_line, 1)
return self:meta_return(first_todo_keyword.value .. ' ')
local level = string.rep('*', item:get_level()) .. ' '
local line = config:respect_blank_before_new_entry({ level .. first_todo_keyword })
local start_line = item:get_range().start_line
vim.fn.append(start_line, line)
vim.fn.cursor(start_line + #line, 1)
end
end

Expand Down

0 comments on commit 4471164

Please sign in to comment.