|
|
@ -162,6 +162,7 @@ local function setup_buffer_keymaps()
|
|
|
|
local function press_enter()
|
|
|
|
local function press_enter()
|
|
|
|
local details, lnum = get_current_line_details_with_cursor() -- Use basic helper is fine
|
|
|
|
local details, lnum = get_current_line_details_with_cursor() -- Use basic helper is fine
|
|
|
|
if not details then
|
|
|
|
if not details then
|
|
|
|
|
|
|
|
vim.notify("[Todoer Debug] press_enter: Failed to get details", vim.log.levels.WARN)
|
|
|
|
-- Getting details failed, do nothing and let Neovim handle Enter.
|
|
|
|
-- Getting details failed, do nothing and let Neovim handle Enter.
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -170,7 +171,16 @@ local function setup_buffer_keymaps()
|
|
|
|
-- Use string.match with %S to check for any non-whitespace character
|
|
|
|
-- Use string.match with %S to check for any non-whitespace character
|
|
|
|
local has_content = details.content and string.match(details.content, "%S")
|
|
|
|
local has_content = details.content and string.match(details.content, "%S")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ===== DEBUGGING START =====
|
|
|
|
|
|
|
|
vim.notify(string.format("[Todoer Debug] press_enter:\n is_todo: %s\n content: %s\n has_content (match %%S): %s",
|
|
|
|
|
|
|
|
tostring(details.is_todo),
|
|
|
|
|
|
|
|
vim.inspect(details.content), -- Use inspect to see quotes/details
|
|
|
|
|
|
|
|
tostring(has_content) -- Convert potential match result to string
|
|
|
|
|
|
|
|
), vim.log.levels.INFO)
|
|
|
|
|
|
|
|
-- ===== DEBUGGING END =====
|
|
|
|
|
|
|
|
|
|
|
|
if details.is_todo and has_content then
|
|
|
|
if details.is_todo and has_content then
|
|
|
|
|
|
|
|
vim.notify("[Todoer Debug] press_enter: Entered BRANCH 1 (is_todo and has_content)", vim.log.levels.INFO)
|
|
|
|
-- Case 1: Non-empty TODO line
|
|
|
|
-- Case 1: Non-empty TODO line
|
|
|
|
-- Create a new TODO line below with same indent/marker
|
|
|
|
-- Create a new TODO line below with same indent/marker
|
|
|
|
local new_marker = details.marker or "-" -- Should always have marker if is_todo, but safety check
|
|
|
|
local new_marker = details.marker or "-" -- Should always have marker if is_todo, but safety check
|
|
|
@ -187,6 +197,7 @@ local function setup_buffer_keymaps()
|
|
|
|
-- No return value needed as it's not an expr mapping anymore.
|
|
|
|
-- No return value needed as it's not an expr mapping anymore.
|
|
|
|
|
|
|
|
|
|
|
|
elseif details.is_todo and not has_content then
|
|
|
|
elseif details.is_todo and not has_content then
|
|
|
|
|
|
|
|
vim.notify("[Todoer Debug] press_enter: Entered BRANCH 2 (is_todo and not has_content)", vim.log.levels.INFO)
|
|
|
|
-- Case 2: Empty TODO line (e.g., "- [ ]") - Implement Outdenting
|
|
|
|
-- Case 2: Empty TODO line (e.g., "- [ ]") - Implement Outdenting
|
|
|
|
local current_indent = details.indent
|
|
|
|
local current_indent = details.indent
|
|
|
|
local current_indent_len = #current_indent
|
|
|
|
local current_indent_len = #current_indent
|
|
|
@ -194,6 +205,7 @@ local function setup_buffer_keymaps()
|
|
|
|
local et = vim.bo.expandtab -- Get buffer's expandtab setting
|
|
|
|
local et = vim.bo.expandtab -- Get buffer's expandtab setting
|
|
|
|
|
|
|
|
|
|
|
|
if current_indent_len > 0 then
|
|
|
|
if current_indent_len > 0 then
|
|
|
|
|
|
|
|
vim.notify("[Todoer Debug] press_enter: Branch 2 - Outdenting", vim.log.levels.INFO)
|
|
|
|
-- Line is indented, calculate new indentation
|
|
|
|
-- Line is indented, calculate new indentation
|
|
|
|
local new_indent = ""
|
|
|
|
local new_indent = ""
|
|
|
|
if et then -- Using spaces
|
|
|
|
if et then -- Using spaces
|
|
|
@ -222,6 +234,7 @@ local function setup_buffer_keymaps()
|
|
|
|
-- Action handled, do not fall through.
|
|
|
|
-- Action handled, do not fall through.
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
vim.notify("[Todoer Debug] press_enter: Branch 2 - Terminating list", vim.log.levels.INFO)
|
|
|
|
-- Line is not indented, terminate the list
|
|
|
|
-- Line is not indented, terminate the list
|
|
|
|
-- Replace the line with an empty string
|
|
|
|
-- Replace the line with an empty string
|
|
|
|
vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { "" })
|
|
|
|
vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { "" })
|
|
|
@ -234,6 +247,7 @@ local function setup_buffer_keymaps()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
vim.notify("[Todoer Debug] press_enter: Entered BRANCH 3 (Not a TODO or fallback)", vim.log.levels.INFO)
|
|
|
|
-- Case 3: Not a TODO line
|
|
|
|
-- Case 3: Not a TODO line
|
|
|
|
-- Do nothing. Neovim will automatically handle the Enter key press
|
|
|
|
-- Do nothing. Neovim will automatically handle the Enter key press
|
|
|
|
-- because this function didn't modify the buffer or explicitly handle it.
|
|
|
|
-- because this function didn't modify the buffer or explicitly handle it.
|
|
|
|