From 44711643309990adcafae0f5784874537675e251 Mon Sep 17 00:00:00 2001 From: Matthias Bidlingmeyer Date: Sun, 27 Oct 2024 11:21:39 +0100 Subject: [PATCH] fix(insert_todo): use the new meta return to skip content --- lua/orgmode/org/mappings.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lua/orgmode/org/mappings.lua b/lua/orgmode/org/mappings.lua index 38228adb..8f6b34b7 100644 --- a/lua/orgmode/org/mappings.lua +++ b/lua/orgmode/org/mappings.lua @@ -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 @@ -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