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,6 +2381,15 @@ 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;
if (start_token->type == CPP_TOKEN_PARENTHESE_OPEN){
if (start_token == tokens.tokens){
found_safe_start_position = 1;
}
else{
token = start_token-1;
}
}
else{
int close = 0; int close = 0;
for (token = start_token; token < brace_token; ++token){ for (token = start_token; token < brace_token; ++token){
@ -2399,19 +2408,23 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
case CPP_TOKEN_PARENTHESE_CLOSE: case CPP_TOKEN_PARENTHESE_CLOSE:
token = seek_matching_token_backwards(tokens, token-1, token = seek_matching_token_backwards(tokens, token-1,
CPP_TOKEN_PARENTHESE_OPEN, CPP_TOKEN_PARENTHESE_CLOSE); CPP_TOKEN_PARENTHESE_OPEN,
CPP_TOKEN_PARENTHESE_CLOSE);
break; break;
case CPP_TOKEN_BRACKET_CLOSE: case CPP_TOKEN_BRACKET_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_BRACKET_OPEN,
CPP_TOKEN_BRACKET_CLOSE);
break; break;
case CPP_TOKEN_BRACE_CLOSE: case CPP_TOKEN_BRACE_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_BRACE_OPEN,
CPP_TOKEN_BRACE_CLOSE);
break; break;
} }
}
} while(found_safe_start_position == 0); } while(found_safe_start_position == 0);
// NOTE(allen): Shift the array so that line_i can just operate in // NOTE(allen): Shift the array so that line_i can just operate in