Skip to content

Commit 8af19ec

Browse files
authored
fmt: allow align threshold to be parametrized in calls to add_new_info (#21942)
1 parent 1b7b812 commit 8af19ec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

vlib/v/fmt/align.v

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ module fmt
55

66
import v.mathutil
77

8-
const struct_field_align_threshold = 8
9-
108
struct AlignInfo {
119
mut:
1210
line_nr int
@@ -18,6 +16,7 @@ mut:
1816
struct AddInfoConfig {
1917
pub:
2018
use_threshold bool
19+
threshold int = 8
2120
}
2221

2322
fn (mut infos []AlignInfo) add_new_info(len int, type_len int, line int) {
@@ -43,7 +42,7 @@ fn (mut infos []AlignInfo) add_info(len int, type_len int, line int, cfg AddInfo
4342
len_diff := mathutil.abs(infos[i].max_len - len) +
4443
mathutil.abs(infos[i].max_type_len - type_len)
4544

46-
if len_diff >= fmt.struct_field_align_threshold {
45+
if len_diff >= cfg.threshold {
4746
infos.add_new_info(len, type_len, line)
4847
return
4948
}

0 commit comments

Comments
 (0)