Skip to content

Commit

Permalink
fix: when there are 4 authors, set div to 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukusuket committed Aug 12, 2024
1 parent 5ac0bec commit c784a23
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/afterfact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2103,12 +2103,14 @@ fn output_detected_rule_authors(
let mut sorted_authors: Vec<(&CompactString, &i128)> = rule_author_counter.iter().collect();

sorted_authors.sort_by(|a, b| (-a.1).cmp(&(-b.1)));
let div = if sorted_authors.len() % 4 != 0 {
sorted_authors.len() / table_column_num + 1
let authors_num = sorted_authors.len();
let div = if authors_num <= table_column_num {
1
} else if authors_num % 4 != 0 {
authors_num / table_column_num + 1
} else {
sorted_authors.len() / table_column_num
authors_num / table_column_num
};

let mut tb = Table::new();
tb.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS)
Expand Down

0 comments on commit c784a23

Please sign in to comment.