fixed paren-at-beginning-of-line bug

master
Allen Webster 2016-05-16 13:24:59 -04:00
parent 3710ac41ca
commit 9971323946
1 changed files with 38 additions and 25 deletions

View File

@ -2381,36 +2381,49 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
Cpp_Token *start_token = get_first_token_at_line(buffer, tokens, line); Cpp_Token *start_token = get_first_token_at_line(buffer, tokens, line);
Cpp_Token *brace_token = token; Cpp_Token *brace_token = token;
int close = 0; if (start_token->type == CPP_TOKEN_PARENTHESE_OPEN){
if (start_token == tokens.tokens){
for (token = start_token; token < brace_token; ++token){ found_safe_start_position = 1;
switch(token->type){ }
case CPP_TOKEN_PARENTHESE_CLOSE: else{
case CPP_TOKEN_BRACKET_CLOSE: token = start_token-1;
case CPP_TOKEN_BRACE_CLOSE:
close = token->type;
goto out_of_loop2;
} }
} }
out_of_loop2:; else{
int close = 0;
switch (close){ for (token = start_token; token < brace_token; ++token){
case 0: token = start_token; found_safe_start_position = 1; break; switch(token->type){
case CPP_TOKEN_PARENTHESE_CLOSE:
case CPP_TOKEN_BRACKET_CLOSE:
case CPP_TOKEN_BRACE_CLOSE:
close = token->type;
goto out_of_loop2;
}
}
out_of_loop2:;
case CPP_TOKEN_PARENTHESE_CLOSE: switch (close){
token = seek_matching_token_backwards(tokens, token-1, case 0: token = start_token; found_safe_start_position = 1; break;
CPP_TOKEN_PARENTHESE_OPEN, CPP_TOKEN_PARENTHESE_CLOSE);
break;
case CPP_TOKEN_BRACKET_CLOSE: case CPP_TOKEN_PARENTHESE_CLOSE:
token = seek_matching_token_backwards(tokens, token-1, token = seek_matching_token_backwards(tokens, token-1,
CPP_TOKEN_BRACKET_OPEN, CPP_TOKEN_BRACKET_CLOSE); CPP_TOKEN_PARENTHESE_OPEN,
break; CPP_TOKEN_PARENTHESE_CLOSE);
break;
case CPP_TOKEN_BRACE_CLOSE: case CPP_TOKEN_BRACKET_CLOSE:
token = seek_matching_token_backwards(tokens, token-1, token = seek_matching_token_backwards(tokens, token-1,
CPP_TOKEN_BRACE_OPEN, CPP_TOKEN_BRACE_CLOSE); CPP_TOKEN_BRACKET_OPEN,
break; CPP_TOKEN_BRACKET_CLOSE);
break;
case CPP_TOKEN_BRACE_CLOSE:
token = seek_matching_token_backwards(tokens, token-1,
CPP_TOKEN_BRACE_OPEN,
CPP_TOKEN_BRACE_CLOSE);
break;
}
} }
} while(found_safe_start_position == 0); } while(found_safe_start_position == 0);