Forráskód Böngészése

Use file_name_width in grid

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.
Corey Ford 11 éve
szülő
commit
43e8061996
1 módosított fájl, 3 hozzáadás és 3 törlés
  1. 3 3
      src/output/grid.rs

+ 3 - 3
src/output/grid.rs

@@ -51,7 +51,7 @@ impl Grid {
                 else {
                 else {
                     index / num_lines
                     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!
             // If they all fit in the terminal, combined, then success!
@@ -87,8 +87,8 @@ impl Grid {
                         print!("{}", styled_name);
                         print!("{}", styled_name);
                     }
                     }
                     else {
                     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");
                 print!("\n");