mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Fix: Bug: names may be shortened unnecessarily
The code calculating the width of a row to use vs the width of the terminal wasn't quite right. If we had 2 long filepaths one at the top of the dir tree and one at the bottom the old code would shorten both equally. This doesn't make sense as the one at the shallowest part of the tree would have used less screen real estate and so should show a longer part of the filepath.
This commit is contained in:
@@ -141,7 +141,7 @@ pub fn test_substring_of_names_and_long_names() {
|
||||
|
||||
fn no_substring_of_names_output() -> Vec<String> {
|
||||
let ubuntu = "
|
||||
0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_g..
|
||||
0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_goe..
|
||||
4.0K ├── dir_name_clash
|
||||
4.0K │ ┌── hello
|
||||
8.0K ├─┴ dir
|
||||
@@ -153,7 +153,7 @@ fn no_substring_of_names_output() -> Vec<String> {
|
||||
.into();
|
||||
|
||||
let mac_and_some_linux = "
|
||||
0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_g..
|
||||
0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_goe..
|
||||
4.0K │ ┌── hello
|
||||
4.0K ├─┴ dir
|
||||
4.0K ├── dir_name_clash
|
||||
|
||||
@@ -24,7 +24,7 @@ fn get_width_of_terminal() -> u16 {
|
||||
|
||||
// Mac test runners create tmp files with very long names, hence it may be shortened in the output
|
||||
fn get_file_name(name: String) -> String {
|
||||
let terminal_plus_buffer = (get_width_of_terminal() - 14) as usize;
|
||||
let terminal_plus_buffer = (get_width_of_terminal() - 12) as usize;
|
||||
if UnicodeWidthStr::width(&*name) > terminal_plus_buffer {
|
||||
let trimmed_name = name
|
||||
.chars()
|
||||
|
||||
Reference in New Issue
Block a user