1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-16 18:21:01 +00:00

df: fix "File" column width for unicode filenames

Fixes #3425
This commit is contained in:
Daniel Hofstetter 2022-04-19 10:40:10 +02:00
parent 346902e30b
commit 9de407b1f0
4 changed files with 20 additions and 2 deletions

View file

@ -18,6 +18,7 @@ path = "src/df.rs"
clap = { version = "3.1", features = ["wrap_help", "cargo"] }
number_prefix = "0.4"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] }
unicode-width = "0.1.9"
[[bin]]
name = "df"

View file

@ -8,6 +8,7 @@
//! A table ([`Table`]) comprises a header row ([`Header`]) and a
//! collection of data rows ([`Row`]), one per filesystem.
use number_prefix::NumberPrefix;
use unicode_width::UnicodeWidthStr;
use crate::columns::{Alignment, Column};
use crate::filesystem::Filesystem;
@ -362,8 +363,8 @@ impl Table {
total += row;
for (i, value) in values.iter().enumerate() {
if value.len() > widths[i] {
widths[i] = value.len();
if UnicodeWidthStr::width(value.as_str()) > widths[i] {
widths[i] = UnicodeWidthStr::width(value.as_str());
}
}