Skip to content

Commit

Permalink
fmt: allow align threshold to be parametrized in calls to add_new_info (
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 authored Jul 27, 2024
1 parent 1b7b812 commit 8af19ec
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions vlib/v/fmt/align.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module fmt

import v.mathutil

const struct_field_align_threshold = 8

struct AlignInfo {
mut:
line_nr int
Expand All @@ -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) {
Expand All @@ -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
}
Expand Down

0 comments on commit 8af19ec

Please sign in to comment.