From 8af19ece2c5889ad84f431ff8e0d9af7bf0d24ef Mon Sep 17 00:00:00 2001 From: yuyi Date: Sat, 27 Jul 2024 19:47:06 +0800 Subject: [PATCH] fmt: allow align threshold to be parametrized in calls to add_new_info (#21942) --- vlib/v/fmt/align.v | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vlib/v/fmt/align.v b/vlib/v/fmt/align.v index 3c97ddf39a..7a0fafea59 100644 --- a/vlib/v/fmt/align.v +++ b/vlib/v/fmt/align.v @@ -5,8 +5,6 @@ module fmt import v.mathutil -const struct_field_align_threshold = 8 - struct AlignInfo { mut: line_nr int @@ -18,6 +16,7 @@ mut: struct AddInfoConfig { pub: use_threshold bool + threshold int = 8 } 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 len_diff := mathutil.abs(infos[i].max_len - len) + mathutil.abs(infos[i].max_type_len - type_len) - if len_diff >= fmt.struct_field_align_threshold { + if len_diff >= cfg.threshold { infos.add_new_info(len, type_len, line) return }