File tree Expand file tree Collapse file tree 4 files changed +49
-1
lines changed
Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 22
33# Development version
44
5+ - Fixed an issue with Unicode elements and table alignment (#449 ).
6+
7+
58# 0.8.0
69
710- Added support for table formatting of ` tribble() ` and ` fcase() ` calls (#113 ).
Original file line number Diff line number Diff line change @@ -491,7 +491,13 @@ impl ArgKind {
491491 Some ( frac_len) => * integer_width + DOT_WIDTH + * frac_len,
492492 None => * integer_width,
493493 } ,
494- ArgKind :: Other { text } => text. len ( ) ,
494+ ArgKind :: Other { text } => {
495+ // Unlike with integers and decimals, can't use `text.len()` here in case
496+ // Unicode characters are involved. `len()` counts bytes, but we want to
497+ // align based on the number of characters that visibly show up in a
498+ // user's editor (#449).
499+ text. chars ( ) . count ( )
500+ }
495501 }
496502 }
497503}
Original file line number Diff line number Diff line change @@ -407,3 +407,16 @@ list(
407407 # comment
408408 foo = 1 , 2 , 3
409409)
410+
411+ # ------------------------------------------------------------------------
412+ # Unicode
413+
414+ # Width of strings count the number of `chars()` (#449)
415+ # fmt: table
416+ tribble(
417+ ~ col1 , ~ col2 ,
418+ " A (Mio. €)" , 10 ,
419+ " B (T €)" , 20 ,
420+ " C §" , 10 ,
421+ " ascii" , 10 ,
422+ )
Original file line number Diff line number Diff line change @@ -415,6 +415,19 @@ list(
415415 foo = 1, 2, 3
416416)
417417
418+ # ------------------------------------------------------------------------
419+ # Unicode
420+
421+ # Width of strings count the number of ` chars ()` (#449)
422+ # fmt: table
423+ tribble(
424+ ~col1, ~col2,
425+ "A (Mio. €)", 10,
426+ "B (T €)", 20,
427+ "C §", 10,
428+ "ascii", 10,
429+ )
430+
418431` ` `
419432
420433
@@ -848,6 +861,19 @@ list(
848861 2,
849862 3
850863)
864+
865+ # ------------------------------------------------------------------------
866+ # Unicode
867+
868+ # Width of strings count the number of ` chars ()` (#449)
869+ # fmt: table
870+ tribble(
871+ ~col1 , ~col2 ,
872+ "A (Mio. €)" , 10 ,
873+ "B (T €)" , 20 ,
874+ "C §" , 10 ,
875+ "ascii" , 10 ,
876+ )
851877` ` `
852878
853879
You can’t perform that action at this time.
0 commit comments