diff --git a/src/display.rs b/src/display.rs index ab14093..f407284 100644 --- a/src/display.rs +++ b/src/display.rs @@ -148,7 +148,7 @@ pub fn draw_it( if !permissions { eprintln!("Did not have permissions for all directories"); } - let terminal_width = (get_width_of_terminal() - 16) as usize; + let terminal_width = (get_width_of_terminal() - 14) as usize; let num_indent_chars = 3; let longest_string_length = root_node .children diff --git a/tests/tests.rs b/tests/tests.rs index 40c4100..b8fd678 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -95,10 +95,10 @@ pub fn test_main_multi_arg() { #[cfg(target_os = "macos")] fn main_output() -> String { r#" - 0B ┌── a_file │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% - 4.0K ├── hello_file│██████████████████████████████████████████████ │ 100% - 4.0K ┌─┴ many │██████████████████████████████████████████████ │ 100% - 4.0K ┌─┴ test_dir │██████████████████████████████████████████████ │ 100% + 0B ┌── a_file │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 4.0K ├── hello_file│████████████████████████████████████████████████ │ 100% + 4.0K ┌─┴ many │████████████████████████████████████████████████ │ 100% + 4.0K ┌─┴ test_dir │████████████████████████████████████████████████ │ 100% "# .trim() .to_string() @@ -107,10 +107,10 @@ fn main_output() -> String { #[cfg(target_os = "linux")] fn main_output() -> String { r#" - 0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% - 4.0K ├── hello_file│ ░░░░░░░░░░░░░░░████████████████ │ 33% - 8.0K ┌─┴ many │ ███████████████████████████████ │ 67% - 12K ┌─┴ test_dir │██████████████████████████████████████████████ │ 100% + 0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 4.0K ├── hello_file│ ░░░░░░░░░░░░░░░░█████████████████ │ 33% + 8.0K ┌─┴ many │ █████████████████████████████████ │ 67% + 12K ┌─┴ test_dir │████████████████████████████████████████████████ │ 100% "# .trim() .to_string() @@ -133,16 +133,18 @@ pub fn test_main_long_paths() { .unwrap() .stdout; let output = str::from_utf8(&assert).unwrap(); + println!("{:?}", output.trim()); + println!("{:?}", main_output_long_paths().trim()); assert!(output.contains(&main_output_long_paths())); } #[cfg(target_os = "macos")] fn main_output_long_paths() -> String { r#" - 0B ┌── /tmp/test_dir/many/a_file │░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% - 4.0K ├── /tmp/test_dir/many/hello_file│███████████████████████████ │ 100% - 4.0K ┌─┴ /tmp/test_dir/many │███████████████████████████ │ 100% - 4.0K ┌─┴ /tmp/test_dir │███████████████████████████ │ 100% + 0B ┌── /tmp/test_dir/many/a_file │░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 4.0K ├── /tmp/test_dir/many/hello_file│█████████████████████████████ │ 100% + 4.0K ┌─┴ /tmp/test_dir/many │█████████████████████████████ │ 100% + 4.0K ┌─┴ /tmp/test_dir │█████████████████████████████ │ 100% "# .trim() .to_string() @@ -151,10 +153,10 @@ fn main_output_long_paths() -> String { #[cfg(target_os = "linux")] fn main_output_long_paths() -> String { r#" - 0B ┌── /tmp/test_dir/many/a_file │ ░░░░░░░░░░░░░░░░░░█ │ 0% - 4.0K ├── /tmp/test_dir/many/hello_file│ ░░░░░░░░░██████████ │ 33% - 8.0K ┌─┴ /tmp/test_dir/many │ ███████████████████ │ 67% - 12K ┌─┴ /tmp/test_dir │███████████████████████████ │ 100% + 0B ┌── /tmp/test_dir/many/a_file │ ░░░░░░░░░░░░░░░░░░░█ │ 0% + 4.0K ├── /tmp/test_dir/many/hello_file│ ░░░░░░░░░░██████████ │ 33% + 8.0K ┌─┴ /tmp/test_dir/many │ ████████████████████ │ 67% + 12K ┌─┴ /tmp/test_dir │█████████████████████████████ │ 100% "# .trim() .to_string() @@ -178,10 +180,10 @@ pub fn test_apparent_size() { #[cfg(target_os = "linux")] fn output_apparent_size() -> String { r#" - 0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% - 6B ├── hello_file│ ░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% - 4.0K ┌─┴ many │ ████████████████████████ │ 50% - 8.0K ┌─┴ test_dir │██████████████████████████████████████████████ │ 100% + 0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 6B ├── hello_file│ ░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 4.0K ┌─┴ many │ █████████████████████████ │ 50% + 8.0K ┌─┴ test_dir │████████████████████████████████████████████████ │ 100% "# .trim() .to_string() @@ -190,10 +192,10 @@ fn output_apparent_size() -> String { #[cfg(target_os = "macos")] fn output_apparent_size() -> String { r#" - 0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% - 6B ├── hello_file│ ░░░░░░░░░░░░░░░░░░░░░░░░░██ │ 3% - 134B ┌─┴ many │ ███████████████████████████ │ 58% - 230B ┌─┴ test_dir │██████████████████████████████████████████████ │ 100% + 0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0% + 6B ├── hello_file│ ░░░░░░░░░░░░░░░░░░░░░░░░░░██ │ 3% + 134B ┌─┴ many │ ████████████████████████████ │ 58% + 230B ┌─┴ test_dir │████████████████████████████████████████████████ │ 100% "# .trim() .to_string() @@ -250,7 +252,7 @@ pub fn test_substring_of_names_and_long_names() { #[cfg(target_os = "linux")] fn no_substring_of_names_output() -> String { " - 0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this.. + 0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_g.. 4.0K ├── dir_name_clash 4.0K │ ┌── hello 8.0K ├─┴ dir_substring @@ -265,7 +267,7 @@ fn no_substring_of_names_output() -> String { #[cfg(target_os = "macos")] fn no_substring_of_names_output() -> String { " - 0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this.. + 0B ┌── long_dir_name_what_a_very_long_dir_name_what_happens_when_this_g.. 4.0K │ ┌── hello 4.0K ├─┴ dir_substring 4.0K ├── dir_name_clash @@ -296,9 +298,9 @@ pub fn test_unicode_directories() { fn unicode_dir() -> String { // The way unicode & asian characters are rendered on the terminal should make this line up " - 0B ┌── 👩.unicode │ █ │ 0% - 0B ├── ラウトは難しいです!.japan│ █ │ 0% - 4.0K ┌─┴ test_dir3 │████████████████████████████████ │ 100% + 0B ┌── 👩.unicode │ █ │ 0% + 0B ├── ラウトは難しいです!.japan│ █ │ 0% + 4.0K ┌─┴ test_dir3 │██████████████████████████████████ │ 100% " .trim() .into() @@ -307,9 +309,9 @@ fn unicode_dir() -> String { #[cfg(target_os = "macos")] fn unicode_dir() -> String { " - 0B ┌── 👩.unicode │ █ │ 0% - 0B ├── ラウトは難しいです!.japan│ █ │ 0% - 0B ┌─┴ test_dir3 │ █ │ 0% + 0B ┌── 👩.unicode │ █ │ 0% + 0B ├── ラウトは難しいです!.japan│ █ │ 0% + 0B ┌─┴ test_dir3 │ █ │ 0% " .trim() .into() diff --git a/tests/tests_symlinks.rs b/tests/tests_symlinks.rs index c52e483..2dfd4c3 100644 --- a/tests/tests_symlinks.rs +++ b/tests/tests_symlinks.rs @@ -25,7 +25,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() - 16) as usize; + let terminal_plus_buffer = (get_width_of_terminal() - 14) as usize; if UnicodeWidthStr::width(&*name) > terminal_plus_buffer { let trimmed_name = name .chars()