mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
check comma count in enum instead
This commit is contained in:
@@ -486,13 +486,15 @@ align_var_decls :: proc(p: ^Printer) {
|
|||||||
if tokenizer.Token_Kind.B_Keyword_Begin <= line.format_tokens[i].kind && line.format_tokens[i].kind <= tokenizer.Token_Kind.B_Keyword_End {
|
if tokenizer.Token_Kind.B_Keyword_Begin <= line.format_tokens[i].kind && line.format_tokens[i].kind <= tokenizer.Token_Kind.B_Keyword_End {
|
||||||
continue_flag = true;
|
continue_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if continue_flag {
|
if continue_flag {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.println(line);
|
||||||
|
fmt.println(largest_rhs);
|
||||||
|
|
||||||
if line_index != current_line + 1 || typed != current_typed || not_mutable != current_not_mutable {
|
if line_index != current_line + 1 || typed != current_typed || not_mutable != current_not_mutable {
|
||||||
|
|
||||||
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 {
|
||||||
@@ -705,7 +707,7 @@ align_enum :: proc(p: ^Printer, index: int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
largest := 0;
|
largest := 0;
|
||||||
eq_count := 0;
|
comma_count := 0;
|
||||||
|
|
||||||
for line, line_index in p.lines[brace_line + 1:] {
|
for line, line_index in p.lines[brace_line + 1:] {
|
||||||
length := 0;
|
length := 0;
|
||||||
@@ -716,20 +718,21 @@ align_enum :: proc(p: ^Printer, index: int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format_token.kind == .Eq {
|
if format_token.kind == .Eq {
|
||||||
eq_count += 1;
|
|
||||||
largest = max(length, largest);
|
largest = max(length, largest);
|
||||||
break;
|
break;
|
||||||
|
} else if format_token.kind == .Comma {
|
||||||
|
comma_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
length += len(format_token.text) + format_token.spaces_before;
|
length += len(format_token.text) + format_token.spaces_before;
|
||||||
}
|
}
|
||||||
|
|
||||||
if eq_count >= brace_token.parameter_count {
|
if comma_count >= brace_token.parameter_count {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eq_count = 0;
|
comma_count = 0;
|
||||||
|
|
||||||
for line, line_index in p.lines[brace_line + 1:] {
|
for line, line_index in p.lines[brace_line + 1:] {
|
||||||
length := 0;
|
length := 0;
|
||||||
@@ -740,15 +743,16 @@ align_enum :: proc(p: ^Printer, index: int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format_token.kind == .Eq {
|
if format_token.kind == .Eq {
|
||||||
eq_count += 1;
|
|
||||||
line.format_tokens[i].spaces_before = largest - length + 1;
|
line.format_tokens[i].spaces_before = largest - length + 1;
|
||||||
break;
|
break;
|
||||||
|
} else if format_token.kind == .Comma {
|
||||||
|
comma_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
length += len(format_token.text) + format_token.spaces_before;
|
length += len(format_token.text) + format_token.spaces_before;
|
||||||
}
|
}
|
||||||
|
|
||||||
if eq_count >= brace_token.parameter_count {
|
if comma_count >= brace_token.parameter_count {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user