diff --git a/custom/4coder_auto_indent.cpp b/custom/4coder_auto_indent.cpp index 0122730d..7f113ec1 100644 --- a/custom/4coder_auto_indent.cpp +++ b/custom/4coder_auto_indent.cpp @@ -68,7 +68,6 @@ find_anchor_token(Application_Links *app, Buffer_ID buffer, Token_Array *tokens, if (tokens != 0 && tokens->tokens != 0){ result = tokens->tokens; i64 invalid_pos = get_line_start_pos(app, buffer, invalid_line); - i32 scope_counter = 0; i32 paren_counter = 0; Token *token = tokens->tokens; @@ -164,6 +163,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra current_indent = nest->indent; } i64 this_indent = current_indent; + i64 following_indent = current_indent; if (HasFlag(token->flags, TokenBaseFlag_PreprocessorBody)){ this_indent = 0; @@ -176,6 +176,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra sll_stack_push(nest, new_nest); nest->kind = TokenBaseKind_ScopeOpen; nest->indent = current_indent + indent_width; + following_indent = nest->indent; }break; case TokenBaseKind_ScopeClose: @@ -194,6 +195,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra if (nest != 0){ this_indent = nest->indent; } + following_indent = this_indent; }break; case TokenBaseKind_ParentheticalOpen: @@ -202,6 +204,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra sll_stack_push(nest, new_nest); nest->kind = TokenBaseKind_ParentheticalOpen; nest->indent = line_indent_info.indent_pos + (token->pos - line_indent_info.first_char_pos) + 1; + following_indent = nest->indent; }break; case TokenBaseKind_ParentheticalClose: @@ -211,6 +214,10 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra sll_stack_pop(nest); indent__free_nest(&nest_alloc, n); } + following_indent = 0; + if (nest != 0){ + following_indent = nest->indent; + } }break; } } @@ -224,7 +231,6 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra line_it += 1; if (line_it == line_where_token_starts){ EMIT(this_indent); - last_indent = this_indent; } else{ EMIT(last_indent); @@ -243,6 +249,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra } #undef EMIT + last_indent = following_indent; line_last_indented = line_it; if (!token_it_inc_non_whitespace(&token_it)){ diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 51309558..5767820f 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -387,10 +387,10 @@ static Command_Metadata fcoder_metacmd_table[226] = { { PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 847 }, { PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 880 }, { PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 960 }, -{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 313 }, -{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 322 }, -{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 332 }, -{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 342 }, +{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 320 }, +{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 329 }, +{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 339 }, +{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 349 }, { PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 166 }, { PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 172 }, { PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\custom\\4coder_search.cpp", 36, 178 },