Incomplete statement indentation bumps
parent
79dce39db7
commit
dba6cc907a
|
@ -126,6 +126,28 @@ indent__free_nest(Nest_Alloc *alloc, Nest *nest){
|
|||
sll_stack_push(alloc->free_nest, nest);
|
||||
}
|
||||
|
||||
internal b32
|
||||
indent__unfinished_statement(Token *token, Nest *current_nest){
|
||||
b32 result = false;
|
||||
if (current_nest != 0 && current_nest->kind == TokenBaseKind_ScopeOpen){
|
||||
result = true;
|
||||
switch (token->sub_kind){
|
||||
case TokenCppKind_BraceOp:
|
||||
case TokenCppKind_BraceCl:
|
||||
case TokenCppKind_Semicolon:
|
||||
case TokenCppKind_Colon:
|
||||
case TokenCppKind_Comma:
|
||||
{
|
||||
result = false;
|
||||
}break;
|
||||
}
|
||||
if (HasFlag(token->flags, TokenBaseFlag_PreprocessorBody)){
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal i64*
|
||||
get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Range_i64 lines, Indent_Flag flags, i32 tab_width, i32 indent_width){
|
||||
i64 count = lines.max - lines.min + 1;
|
||||
|
@ -152,6 +174,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
i64 line_last_indented = line - 1;
|
||||
i64 last_indent = 0;
|
||||
i64 actual_indent = 0;
|
||||
b32 in_unfinished_statement = false;
|
||||
|
||||
for (;;){
|
||||
Token *token = token_it_read(&token_it);
|
||||
|
@ -223,6 +246,10 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
}
|
||||
}
|
||||
|
||||
if (in_unfinished_statement){
|
||||
this_indent += indent_width;
|
||||
}
|
||||
|
||||
#define EMIT(N) \
|
||||
Stmnt(if (lines.first <= line_it){shifted_indentations[line_it]=N;} \
|
||||
if (line_it == lines.end){goto finished;} \
|
||||
|
@ -251,6 +278,13 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
|||
}
|
||||
#undef EMIT
|
||||
|
||||
if (token->kind != TokenBaseKind_Comment){
|
||||
in_unfinished_statement = indent__unfinished_statement(token, nest);
|
||||
if (in_unfinished_statement){
|
||||
following_indent += indent_width;
|
||||
}
|
||||
}
|
||||
|
||||
last_indent = following_indent;
|
||||
line_last_indented = line_it;
|
||||
|
||||
|
|
|
@ -1132,7 +1132,7 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6
|
|||
view_set_cursor_and_preferred_x(app, view, seek_pos(pos));
|
||||
}
|
||||
|
||||
static void
|
||||
function void
|
||||
query_replace_parameter(Application_Links *app, String_Const_u8 replace_str, i64 start_pos, b32 add_replace_query_bar){
|
||||
Query_Bar replace = {};
|
||||
replace.prompt = string_u8_litexpr("Replace: ");
|
||||
|
|
|
@ -369,7 +369,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
|||
}
|
||||
|
||||
// NOTE(allen): Scan for TODOs and NOTEs
|
||||
{
|
||||
if (global_config.use_comment_keyword){
|
||||
Temp_Memory temp = begin_temp(scratch);
|
||||
String_Const_u8 tail = push_buffer_range(app, scratch, buffer, visible_range);
|
||||
i32 index = 0;
|
||||
|
|
|
@ -385,10 +385,10 @@ static Command_Metadata fcoder_metacmd_table[224] = {
|
|||
{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 841 },
|
||||
{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 874 },
|
||||
{ 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, 954 },
|
||||
{ PROC_LINKS(auto_indent_whole_file, 0), "auto_indent_whole_file", 22, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 322 },
|
||||
{ PROC_LINKS(auto_indent_line_at_cursor, 0), "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, 331 },
|
||||
{ PROC_LINKS(auto_indent_range, 0), "auto_indent_range", 17, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\custom\\4coder_auto_indent.cpp", 41, 341 },
|
||||
{ PROC_LINKS(write_text_and_auto_indent, 0), "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, 351 },
|
||||
{ PROC_LINKS(auto_indent_whole_file, 0), "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), "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), "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), "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(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 },
|
||||
|
|
Loading…
Reference in New Issue