Skip to content

Commit

Permalink
Use file_name_width in grid
Browse files Browse the repository at this point in the history
Filenames with characters that need multiple bytes in UTF-8, and/or
control characters like combining diacritics, would break the grid.
`StrExt::width` seems to do the right thing, and there's conveniently a
function here (which was otherwise unused) to call that.
  • Loading branch information
coyotebush committed Feb 22, 2015
1 parent a4e1719 commit 43e8061
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/output/grid.rs
Expand Up @@ -51,7 +51,7 @@ impl Grid {
else {
index / num_lines
};
column_widths[index] = max(column_widths[index], file.name.len());
column_widths[index] = max(column_widths[index], file.file_name_width());
}

// If they all fit in the terminal, combined, then success!
Expand Down Expand Up @@ -87,8 +87,8 @@ impl Grid {
print!("{}", styled_name);
}
else {
assert!(widths[x] >= file.name.len());
print!("{}", Left.pad_string(&styled_name, widths[x] - file.name.len() + 2));
assert!(widths[x] >= file.file_name_width());
print!("{}", Left.pad_string(&styled_name, widths[x] - file.file_name_width() + 2));
}
}
print!("\n");
Expand Down

0 comments on commit 43e8061

Please sign in to comment.