Skip to content

Commit

Permalink
Correctly compute length of the typing rule bar in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Sep 12, 2024
1 parent e6b72d5 commit 61d8f3e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ nom-supreme = "0.8.0"
serde_json = "1.0.125"
serde = { version = "1.0.208", features = ["derive"] }
serde_yaml = "0.9.34"
ansi-width = "0.1.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
assert_cmd = "2.0.16"
Expand Down
6 changes: 5 additions & 1 deletion src/compute_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ impl<'a> TypingRule<'a> {
preconditions_str = preconditions_str.replace("*q", "reset(q)");
}

let len = max(preconditions_str.len(), postconditions_str.len());
let display_len = ansi_width::ansi_width;
let len = max(
display_len(&preconditions_str),
display_len(&postconditions_str),
);
let bar = "-".repeat(len);
let mut out = String::new();
let _ = write!(&mut out, "{preconditions_str}\n");
Expand Down

0 comments on commit 61d8f3e

Please sign in to comment.