Auto indent fixes
This commit is contained in:
parent
2911974fa0
commit
3084f835e1
|
@ -189,6 +189,8 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
i64 this_indent = current_indent;
|
||||
i64 following_indent = current_indent;
|
||||
|
||||
b32 shift_by_actual_indent = false;
|
||||
b32 ignore_unfinished_statement = false;
|
||||
if (HasFlag(token->flags, TokenBaseFlag_PreprocessorBody)){
|
||||
this_indent = 0;
|
||||
}
|
||||
|
@ -201,6 +203,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
nest->kind = TokenBaseKind_ScopeOpen;
|
||||
nest->indent = current_indent + indent_width;
|
||||
following_indent = nest->indent;
|
||||
ignore_unfinished_statement = true;
|
||||
}break;
|
||||
|
||||
case TokenBaseKind_ScopeClose:
|
||||
|
@ -220,6 +223,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
this_indent = nest->indent;
|
||||
}
|
||||
following_indent = this_indent;
|
||||
ignore_unfinished_statement = true;
|
||||
}break;
|
||||
|
||||
case TokenBaseKind_ParentheticalOpen:
|
||||
|
@ -227,8 +231,9 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
Nest *new_nest = indent__new_nest(arena, &nest_alloc);
|
||||
sll_stack_push(nest, new_nest);
|
||||
nest->kind = TokenBaseKind_ParentheticalOpen;
|
||||
nest->indent = actual_indent + (token->pos - line_indent_info.first_char_pos) + 1;
|
||||
nest->indent = (token->pos - line_indent_info.first_char_pos) + 1;
|
||||
following_indent = nest->indent;
|
||||
shift_by_actual_indent = true;
|
||||
}break;
|
||||
|
||||
case TokenBaseKind_ParentheticalClose:
|
||||
|
@ -242,11 +247,12 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
if (nest != 0){
|
||||
following_indent = nest->indent;
|
||||
}
|
||||
ignore_unfinished_statement = true;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_unfinished_statement){
|
||||
if (in_unfinished_statement && !ignore_unfinished_statement){
|
||||
this_indent += indent_width;
|
||||
}
|
||||
|
||||
|
@ -278,6 +284,11 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
}
|
||||
#undef EMIT
|
||||
|
||||
if (shift_by_actual_indent){
|
||||
nest->indent += actual_indent;
|
||||
following_indent += actual_indent;
|
||||
}
|
||||
|
||||
if (token->kind != TokenBaseKind_Comment){
|
||||
in_unfinished_statement = indent__unfinished_statement(token, nest);
|
||||
if (in_unfinished_statement){
|
||||
|
|
|
@ -362,10 +362,10 @@ static Command_Metadata fcoder_metacmd_table[211] = {
|
|||
{ PROC_LINKS(interactive_new, 0), true, "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 606 },
|
||||
{ PROC_LINKS(interactive_open, 0), true, "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 639 },
|
||||
{ PROC_LINKS(command_lister, 0), true, "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 702 },
|
||||
{ PROC_LINKS(auto_indent_whole_file, 0), false, "auto_indent_whole_file", 22, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 356 },
|
||||
{ PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 365 },
|
||||
{ PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 375 },
|
||||
{ PROC_LINKS(write_text_and_auto_indent, 0), false, "write_text_and_auto_indent", 26, "Inserts text and auto-indents the line on which the cursor sits if any of the text contains 'layout punctuation' such as ;:{}()[]# and new lines.", 145, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 385 },
|
||||
{ PROC_LINKS(auto_indent_whole_file, 0), false, "auto_indent_whole_file", 22, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 367 },
|
||||
{ PROC_LINKS(auto_indent_line_at_cursor, 0), false, "auto_indent_line_at_cursor", 26, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 376 },
|
||||
{ PROC_LINKS(auto_indent_range, 0), false, "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 386 },
|
||||
{ PROC_LINKS(write_text_and_auto_indent, 0), false, "write_text_and_auto_indent", 26, "Inserts text and auto-indents the line on which the cursor sits if any of the text contains 'layout punctuation' such as ;:{}()[]# and new lines.", 145, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 396 },
|
||||
{ PROC_LINKS(list_all_locations, 0), false, "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), false, "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), false, "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 },
|
||||
|
|
Loading…
Reference in New Issue