Skip to content

Commit

Permalink
update unicode-width to 0.2 (#14456)
Browse files Browse the repository at this point in the history
# Description
When looking into #14395, I found that `unicode-width` from 0.1 to 0.2
contains a breaking change, the mainly change is it treats newlines as
width 1. So relative tests(str stats) are broken.
But I think it's ok to adjust the test.

# User-Facing Changes
The output of `str stats` might change if there are `\n` in the input.
### Before
```nushell
> "a\nb" | str stats | get unicode-width
2
```
### After
```nushell
> "a\nb" | str stats | get unicode-width
3
```
# Tests + Formatting
Adjusted 2 tests.

# After Submitting
NaN
  • Loading branch information
WindSoilder authored Nov 29, 2024
1 parent 8d1e36f commit 6e036ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ toml = "0.8"
trash = "5.2"
umask = "2.1"
unicode-segmentation = "1.12"
unicode-width = "0.1"
unicode-width = "0.2"
ureq = { version = "2.10", default-features = false }
url = "2.2"
uu_cp = "0.0.28"
Expand Down
4 changes: 2 additions & 2 deletions crates/nu-command/src/strings/str_/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn test_one_newline() {
correct_counts.insert(Counter::GraphemeClusters, 1);
correct_counts.insert(Counter::Bytes, 1);
correct_counts.insert(Counter::CodePoints, 1);
correct_counts.insert(Counter::UnicodeWidth, 0);
correct_counts.insert(Counter::UnicodeWidth, 1);

assert_eq!(correct_counts, counts);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ fn test_count_counts_lines() {

// one more than grapheme clusters because of \r\n
correct_counts.insert(Counter::CodePoints, 24);
correct_counts.insert(Counter::UnicodeWidth, 17);
correct_counts.insert(Counter::UnicodeWidth, 23);

assert_eq!(correct_counts, counts);
}
Expand Down

0 comments on commit 6e036ca

Please sign in to comment.