Skip to content

Commit

Permalink
feat: use Unicode Standard Annex #11 rules for line width calculation (
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Dec 7, 2022
1 parent 581617f commit dc5ced1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
33 changes: 17 additions & 16 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 @@ -25,7 +25,7 @@ tracing = ["dprint-core/tracing"]

[dependencies]
anyhow = "1.0.64"
dprint-core = { version = "0.59.0", features = ["formatting"] }
dprint-core = { version = "0.60.0", features = ["formatting"] }
pulldown-cmark = { version = "0.9.2", default-features = false }
regex = "1"
serde = { version = "1.0.144", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ fn clone_items(items: PrintItems) -> (PrintItems, PrintItems) {
}

fn measure_single_line_width(items: PrintItems) -> usize {
get_items_text(items).width()
UnicodeWidthStr::width(get_items_text(items).as_str())
}

fn get_items_text(items: PrintItems) -> String {
Expand Down
9 changes: 9 additions & 0 deletions tests/specs/Text/Text_TextWrap_Always.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ testing testing testing testing testing `code` testing testing testing 

[expect]
testing testing testing testing testing `code` testing testing testing testing `code` testing

!! should wrap according to Unicode Standard Annex #11 rules !!
대충 한국어로 아무 말이나 적고 있습니다. '아무말'은 표준국어대사전에 등재되지 않은 단어이므로 '아무 말'로 띄어 씁니다. 아무 말일까요? 누군가에게는

[expect]
대충 한국어로 아무 말이나 적고 있습니다.
'아무말'은 표준국어대사전에 등재되지
않은 단어이므로 '아무 말'로 띄어 씁니다.
아무 말일까요? 누군가에게는

0 comments on commit dc5ced1

Please sign in to comment.