Fixed paren-statement interaction in indentation logic
parent
8e390db03c
commit
f8297dc036
|
@ -265,7 +265,7 @@ get_indentation_array(Application_Links *app, Arena *arena, Buffer_ID buffer, Ra
|
||||||
if (nest != 0){
|
if (nest != 0){
|
||||||
following_indent = nest->indent;
|
following_indent = nest->indent;
|
||||||
}
|
}
|
||||||
ignore_unfinished_statement = true;
|
//ignore_unfinished_statement = true;
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ struct: "struct" <identifier> $(";" | "{")
|
||||||
union: "union" <identifier> $(";" | "{")
|
union: "union" <identifier> $(";" | "{")
|
||||||
enum: "enum" <identifier> $(";" | "{")
|
enum: "enum" <identifier> $(";" | "{")
|
||||||
typedef: "typedef" [* - (<identifier> (";" | "("))] <identifier> $(";" | "(")
|
typedef: "typedef" [* - (<identifier> (";" | "("))] <identifier> $(";" | "(")
|
||||||
function: <identifier> >"(" [* - ("(" | ")" | "{" | "}" | ";")] ")" ("{" | ";")
|
function: <identifier> >"(" ["(" ")" | * - ("(" | ")")] ")" ("{" | ";")
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -359,6 +359,7 @@ cpp_parse_function(Code_Index_File *index, Generic_Parse_State *state, Code_Inde
|
||||||
Token *reset_point = peek;
|
Token *reset_point = peek;
|
||||||
if (peek != 0 && peek->sub_kind == TokenCppKind_ParenOp){
|
if (peek != 0 && peek->sub_kind == TokenCppKind_ParenOp){
|
||||||
b32 at_paren_close = false;
|
b32 at_paren_close = false;
|
||||||
|
i32 paren_nest_level = 0;
|
||||||
for (; peek != 0;){
|
for (; peek != 0;){
|
||||||
generic_parse_inc(state);
|
generic_parse_inc(state);
|
||||||
generic_parse_skip_soft_tokens(index, state);
|
generic_parse_skip_soft_tokens(index, state);
|
||||||
|
@ -367,15 +368,17 @@ cpp_parse_function(Code_Index_File *index, Generic_Parse_State *state, Code_Inde
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peek->kind == TokenBaseKind_ParentheticalOpen ||
|
if (peek->kind == TokenBaseKind_ParentheticalOpen){
|
||||||
peek->kind == TokenBaseKind_ScopeOpen ||
|
paren_nest_level += 1;
|
||||||
peek->kind == TokenBaseKind_ScopeClose ||
|
|
||||||
peek->kind == TokenBaseKind_StatementClose){
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (peek->kind == TokenBaseKind_ParentheticalClose){
|
else if (peek->kind == TokenBaseKind_ParentheticalClose){
|
||||||
at_paren_close = true;
|
if (paren_nest_level > 0){
|
||||||
break;
|
paren_nest_level -= 1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
at_paren_close = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +389,7 @@ cpp_parse_function(Code_Index_File *index, Generic_Parse_State *state, Code_Inde
|
||||||
if (peek != 0 &&
|
if (peek != 0 &&
|
||||||
peek->kind == TokenBaseKind_ScopeOpen ||
|
peek->kind == TokenBaseKind_ScopeOpen ||
|
||||||
peek->kind == TokenBaseKind_StatementClose){
|
peek->kind == TokenBaseKind_StatementClose){
|
||||||
index_new_note(index, state, Ii64(token), CodeIndexNote_Function, parent);
|
index_new_note(index, state, Ii64(token), CodeIndexNote_Function, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,15 +576,22 @@ generic_parse_scope(Code_Index_File *index, Generic_Parse_State *state){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (token->kind == TokenBaseKind_ParentheticalClose){
|
||||||
|
generic_parse_inc(state);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (token->kind == TokenBaseKind_ParentheticalOpen){
|
if (token->kind == TokenBaseKind_ParentheticalOpen){
|
||||||
Code_Index_Nest *nest = generic_parse_paren(index, state);
|
Code_Index_Nest *nest = generic_parse_paren(index, state);
|
||||||
nest->parent = result;
|
nest->parent = result;
|
||||||
code_index_push_nest(&result->nest_list, nest);
|
code_index_push_nest(&result->nest_list, nest);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token->kind == TokenBaseKind_ParentheticalClose){
|
// NOTE(allen): after a parenthetical group we consider ourselves immediately
|
||||||
generic_parse_inc(state);
|
// transitioning into a statement
|
||||||
|
nest = generic_parse_statement(index, state);
|
||||||
|
nest->parent = result;
|
||||||
|
code_index_push_nest(&result->nest_list, nest);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -461,7 +461,7 @@ static Command_Metadata fcoder_metacmd_table[229] = {
|
||||||
{ PROC_LINKS(toggle_mouse, 0), false, "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 415 },
|
{ PROC_LINKS(toggle_mouse, 0), false, "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 415 },
|
||||||
{ PROC_LINKS(toggle_paren_matching_helper, 0), false, "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 445 },
|
{ PROC_LINKS(toggle_paren_matching_helper, 0), false, "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 445 },
|
||||||
{ PROC_LINKS(toggle_show_whitespace, 0), false, "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 710 },
|
{ PROC_LINKS(toggle_show_whitespace, 0), false, "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 710 },
|
||||||
{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1160 },
|
{ PROC_LINKS(toggle_virtual_whitespace, 0), false, "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\custom\\4coder_code_index.cpp", 40, 1170 },
|
||||||
{ PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 },
|
{ PROC_LINKS(tutorial_maximize, 0), false, "tutorial_maximize", 17, "Expand the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 20 },
|
||||||
{ PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 },
|
{ PROC_LINKS(tutorial_minimize, 0), false, "tutorial_minimize", 17, "Shrink the tutorial window", 26, "w:\\4ed\\code\\custom\\4coder_tutorial.cpp", 38, 34 },
|
||||||
{ PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 },
|
{ PROC_LINKS(uncomment_line, 0), false, "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 137 },
|
||||||
|
|
Loading…
Reference in New Issue