mirror of
https://github.com/vlang/v.git
synced 2025-09-13 01:16:02 -04:00
fmt: allow align threshold to be parametrized in calls to add_new_info (#21942)
This commit is contained in:
parent
1b7b8123ca
commit
8af19ece2c
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user