|  |  | @ -140,17 +140,47 @@ local function setup_buffer_keymaps() | 
			
		
	
		
		
			
				
					
					|  |  |  |             return "" |  |  |  |             return "" | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         elseif details.is_todo and not has_content then |  |  |  |         elseif details.is_todo and not has_content then | 
			
		
	
		
		
			
				
					
					|  |  |  |             -- Case 2: Empty TODO line (e.g., "- [ ]") |  |  |  |             -- Case 2: Empty TODO line (e.g., "- [ ]") - Implement Outdenting | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- TODO: Implement Step 3 logic (outdenting) here later. |  |  |  |             local current_indent = details.indent | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- For now, keep the old (potentially problematic) feedkeys behavior |  |  |  |             local current_indent_len = #current_indent | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- or simply clear the line and let Neovim handle Enter. |  |  |  |             local sw = vim.bo.shiftwidth -- Get buffer's shiftwidth | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- Let's try clearing the line and returning <CR> for now. |  |  |  |             local et = vim.bo.expandtab -- Get buffer's expandtab setting | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { details.indent }) -- Replace with just indent |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             return vim.api.nvim_replace_termcodes("<CR>", true, false, true) -- Let Neovim handle newline |  |  |  |             if current_indent_len > 0 then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                 -- Line is indented, calculate new indentation | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- Old feedkeys behavior (kept for reference, but commented out): |  |  |  |                 local new_indent = "" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>S<CR>", true, false, true), "n", false) |  |  |  |                 if et then -- Using spaces | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             -- return "" -- Feedkeys handles it |  |  |  |                     local target_indent_len = math.max(0, current_indent_len - sw) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     new_indent = string.rep(" ", target_indent_len) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 else -- Using tabs | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     -- Remove the first tab character found | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     new_indent = string.gsub(current_indent, "^\t", "", 1) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     -- Safety check: if gsub didn't change anything (e.g., indent was spaces), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     -- try removing spaces as a fallback, though this is less ideal with noexpandtab | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if new_indent == current_indent and current_indent_len > 0 then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                        local target_indent_len = math.max(0, current_indent_len - sw) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                        new_indent = string.rep(" ", target_indent_len) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 -- Replace the current line with the outdented version | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 local new_marker = details.marker or "-" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 local new_line_content = new_indent .. new_marker .. " [ ] " | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { new_line_content }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 -- Move cursor after the "] " on the modified line | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 local cursor_col_bytes = #new_line_content | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 vim.api.nvim_win_set_cursor(0, { lnum, cursor_col_bytes }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 -- Action handled | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 return "" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 -- Line is not indented, terminate the list | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 -- Replace the line with an empty string | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { "" }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 -- Let Neovim handle inserting a newline below the now-empty line | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 return vim.api.nvim_replace_termcodes("<CR>", true, false, true) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         else |  |  |  |         else | 
			
		
	
		
		
			
				
					
					|  |  |  |             -- Case 3: Not a TODO line |  |  |  |             -- Case 3: Not a TODO line | 
			
		
	
	
		
		
			
				
					|  |  | 
 |