Skip to content

Commit

Permalink
feat(list): use unicode-width for alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed Aug 9, 2024
1 parent ffeea6d commit 302b7e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 7 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 @@ -24,6 +24,7 @@ simd-json = "0.13.10"
strsim = "0.11.1"
terminal_size = "0.3.0"
thiserror = "1.0.63"
unicode-width = "0.1.13"

[dev-dependencies]
trycmd = "0.15.6"
Expand Down
3 changes: 2 additions & 1 deletion src/cli/list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use color_eyre::eyre::Result;
use owo_colors::{OwoColorize as _, Stream};
use terminal_size::terminal_size;
use unicode_width::UnicodeWidthStr as _;

use crate::package_json::PackageJson;
use std::{
Expand All @@ -25,7 +26,7 @@ pub fn handle(package_paths: impl Iterator<Item = PathBuf>) -> Result<bool> {
let longest_pad = package
.scripts
.iter()
.map(|s| s.0.len())
.map(|s| s.0.width())
.max()
.unwrap_or_default();

Expand Down

0 comments on commit 302b7e3

Please sign in to comment.