|  |  | @ -77,6 +77,19 @@ local function get_indent_string() | 
			
		
	
		
		
			
				
					
					|  |  |  |     return et and string.rep(" ", sw) or "\t" |  |  |  |     return et and string.rep(" ", sw) or "\t" | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  | end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | -- Debug helper to print line details | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | local function debug_line(msg, details) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     print(string.format( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         "[DEBUG] %s:\n  indent: '%s' (len=%d)\n  marker: '%s'\n  content: '%s'\n  is_todo: %s", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         msg, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         details.indent, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         #details.indent, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         details.marker or "nil", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         details.content, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         details.is_todo | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     )) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- Helper: Gets details for the current line including cursor position |  |  |  | -- Helper: Gets details for the current line including cursor position | 
			
		
	
		
		
			
				
					
					|  |  |  | local function get_current_line_details_with_cursor() |  |  |  | local function get_current_line_details_with_cursor() | 
			
		
	
		
		
			
				
					
					|  |  |  |     local cursor_pos = vim.api.nvim_win_get_cursor(0) |  |  |  |     local cursor_pos = vim.api.nvim_win_get_cursor(0) | 
			
		
	
	
		
		
			
				
					|  |  | @ -275,14 +288,23 @@ local function setup_buffer_keymaps() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     -- Handle tab indentation for TODO lines |  |  |  |     -- Handle tab indentation for TODO lines | 
			
		
	
		
		
			
				
					
					|  |  |  |     local function press_tab() |  |  |  |     local function press_tab() | 
			
		
	
		
		
			
				
					
					|  |  |  |         local details = get_line_details(vim.api.nvim_win_get_cursor(0)[1]) |  |  |  |         local lnum = vim.api.nvim_win_get_cursor(0)[1] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         local details = get_line_details(lnum) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print("\n[DEBUG TAB] Line "..lnum.." before:") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         debug_line("Original", details) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         if not details or not details.is_todo then |  |  |  |         if not details or not details.is_todo then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             print("[DEBUG TAB] Not a TODO line, using default Tab") | 
			
		
	
		
		
			
				
					
					|  |  |  |             return vim.api.nvim_replace_termcodes("<Tab>", true, false, true) |  |  |  |             return vim.api.nvim_replace_termcodes("<Tab>", true, false, true) | 
			
		
	
		
		
			
				
					
					|  |  |  |         end |  |  |  |         end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         local indent_str = get_indent_string() |  |  |  |         local indent_str = get_indent_string() | 
			
		
	
		
		
			
				
					
					|  |  |  |         local new_line = details.indent .. indent_str ..  |  |  |  |         local new_line = details.indent .. indent_str ..  | 
			
		
	
		
		
			
				
					
					|  |  |  |                        (details.marker or "-") .. " [ ] " .. details.content |  |  |  |                        (details.marker or "-") .. " [ ] " .. details.content | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print("[DEBUG TAB] New line will be:", new_line) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print("[DEBUG TAB] Indent string:", "'"..indent_str.."' (length="..#indent_str..")") | 
			
		
	
		
		
			
				
					
					|  |  |  |         vim.api.nvim_set_current_line(new_line) |  |  |  |         vim.api.nvim_set_current_line(new_line) | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         -- Calculate new cursor column (preserve relative position) |  |  |  |         -- Calculate new cursor column (preserve relative position) | 
			
		
	
	
		
		
			
				
					|  |  | @ -295,8 +317,14 @@ local function setup_buffer_keymaps() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     -- Handle shift-tab outdentation for TODO lines |  |  |  |     -- Handle shift-tab outdentation for TODO lines | 
			
		
	
		
		
			
				
					
					|  |  |  |     local function press_shift_tab() |  |  |  |     local function press_shift_tab() | 
			
		
	
		
		
			
				
					
					|  |  |  |         local details = get_line_details(vim.api.nvim_win_get_cursor(0)[1]) |  |  |  |         local lnum = vim.api.nvim_win_get_cursor(0)[1] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         local details = get_line_details(lnum) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print("\n[DEBUG SHIFT-TAB] Line "..lnum.." before:") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         debug_line("Original", details) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         if not details or not details.is_todo or #details.indent == 0 then |  |  |  |         if not details or not details.is_todo or #details.indent == 0 then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             print("[DEBUG SHIFT-TAB] Not a TODO line or at min indent, using default S-Tab") | 
			
		
	
		
		
			
				
					
					|  |  |  |             return vim.api.nvim_replace_termcodes("<S-Tab>", true, false, true) |  |  |  |             return vim.api.nvim_replace_termcodes("<S-Tab>", true, false, true) | 
			
		
	
		
		
			
				
					
					|  |  |  |         end |  |  |  |         end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -304,6 +332,9 @@ local function setup_buffer_keymaps() | 
			
		
	
		
		
			
				
					
					|  |  |  |         local new_indent = details.indent:sub(1, -sw - 1) |  |  |  |         local new_indent = details.indent:sub(1, -sw - 1) | 
			
		
	
		
		
			
				
					
					|  |  |  |         local new_line = new_indent ..  |  |  |  |         local new_line = new_indent ..  | 
			
		
	
		
		
			
				
					
					|  |  |  |                        (details.marker or "-") .. " [ ] " .. details.content |  |  |  |                        (details.marker or "-") .. " [ ] " .. details.content | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print("[DEBUG SHIFT-TAB] New indent:", "'"..new_indent.."' (length="..#new_indent..")") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print("[DEBUG SHIFT-TAB] New line will be:", new_line) | 
			
		
	
		
		
			
				
					
					|  |  |  |         vim.api.nvim_set_current_line(new_line) |  |  |  |         vim.api.nvim_set_current_line(new_line) | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         -- Calculate new cursor column (preserve relative position) |  |  |  |         -- Calculate new cursor column (preserve relative position) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |