This commit is contained in:
Daniel Gavin
2021-04-23 22:55:59 +02:00
parent 951e940470
commit aafbf5bac7
2 changed files with 11 additions and 11 deletions
+10 -10
View File
@@ -460,7 +460,7 @@ align_var_decls :: proc(p: ^Printer) {
}; };
colon_tokens := make([dynamic]TokenAndLength, 0, 10, context.temp_allocator); colon_tokens := make([dynamic]TokenAndLength, 0, 10, context.temp_allocator);
type_tokens := make([dynamic]TokenAndLength, 0, 10, context.temp_allocator); type_tokens := make([dynamic]TokenAndLength, 0, 10, context.temp_allocator);
equal_tokens := make([dynamic]TokenAndLength, 0, 10, context.temp_allocator); equal_tokens := make([dynamic]TokenAndLength, 0, 10, context.temp_allocator);
for line, line_index in p.lines { for line, line_index in p.lines {
@@ -483,10 +483,11 @@ align_var_decls :: proc(p: ^Printer) {
not_mutable = true; not_mutable = true;
} }
if line.format_tokens[i].kind == .Proc || if line.format_tokens[i].kind == .Proc ||
line.format_tokens[i].kind == .Union || line.format_tokens[i].kind == .Union ||
line.format_tokens[i].kind == .Enum || line.format_tokens[i].kind == .Enum ||
line.format_tokens[i].kind == .Struct { line.format_tokens[i].kind == .Struct ||
line.format_tokens[i].kind == .For {
continue_flag = true; continue_flag = true;
} }
@@ -503,7 +504,6 @@ align_var_decls :: proc(p: ^Printer) {
if p.config.align_style == .Align_On_Colon_And_Equals || !current_typed || current_not_mutable { if p.config.align_style == .Align_On_Colon_And_Equals || !current_typed || current_not_mutable {
for colon_token in colon_tokens { for colon_token in colon_tokens {
fmt.println(colon_token);
colon_token.format_token.spaces_before = largest_lhs - colon_token.length + 1; colon_token.format_token.spaces_before = largest_lhs - colon_token.length + 1;
} }
} else if p.config.align_style == .Align_On_Type_And_Equals { } else if p.config.align_style == .Align_On_Type_And_Equals {
@@ -625,7 +625,7 @@ align_switch_stmt :: proc(p: ^Printer, index: int) {
length: int, length: int,
}; };
format_tokens := make([dynamic] TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator); format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator);
//find all the switch cases that are one lined //find all the switch cases that are one lined
for line, line_index in p.lines[brace_line + 1:] { for line, line_index in p.lines[brace_line + 1:] {
@@ -642,7 +642,7 @@ align_switch_stmt :: proc(p: ^Printer, index: int) {
//this will only happen if the case is one lined //this will only happen if the case is one lined
if case_found && colon_found { if case_found && colon_found {
append(&format_tokens, TokenAndLength { format_token = &line.format_tokens[i], length = length }); append(&format_tokens, TokenAndLength {format_token = &line.format_tokens[i], length = length});
largest = max(length, largest); largest = max(length, largest);
break; break;
} }
@@ -699,7 +699,7 @@ align_enum :: proc(p: ^Printer, index: int) {
length: int, length: int,
}; };
format_tokens := make([dynamic] TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator); format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator);
for line, line_index in p.lines[brace_line + 1:] { for line, line_index in p.lines[brace_line + 1:] {
length := 0; length := 0;
@@ -710,7 +710,7 @@ align_enum :: proc(p: ^Printer, index: int) {
} }
if format_token.kind == .Eq { if format_token.kind == .Eq {
append(&format_tokens, TokenAndLength { format_token = &line.format_tokens[i], length = length }); append(&format_tokens, TokenAndLength {format_token = &line.format_tokens[i], length = length});
largest = max(length, largest); largest = max(length, largest);
break; break;
} else if format_token.kind == .Comma { } else if format_token.kind == .Comma {
@@ -764,7 +764,7 @@ align_struct :: proc(p: ^Printer, index: int) {
length: int, length: int,
}; };
format_tokens := make([] TokenAndLength, brace_token.parameter_count, context.temp_allocator); format_tokens := make([]TokenAndLength, brace_token.parameter_count, context.temp_allocator);
for line, line_index in p.lines[brace_line + 1:] { for line, line_index in p.lines[brace_line + 1:] {
length := 0; length := 0;
@@ -781,7 +781,7 @@ align_struct :: proc(p: ^Printer, index: int) {
} }
if format_token.kind == .Colon { if format_token.kind == .Colon {
format_tokens[colon_count] = { format_token = &line.format_tokens[i + 1], length = length }; format_tokens[colon_count] = {format_token = &line.format_tokens[i + 1], length = length};
colon_count += 1; colon_count += 1;
largest = max(length, largest); largest = max(length, largest);
} }
+1 -1
View File
@@ -42,7 +42,7 @@ comment_before_position :: proc(p: ^Printer, pos: tokenizer.Pos) -> bool {
} }
@(private) @(private)
next_comment_group :: proc(p: ^Printer) { next_comment_group :: proc(p: ^Printer) {
p.latest_comment_index += 1; p.latest_comment_index += 1;
} }