Skip to content

Commit fac04a5

Browse files
committed
pin unicode-width below v0.1.13 to fix rendering issues
unicode-width's change "Control characters have width 1" between versions 0.1.12 and 0.1.13 changed the logic so that control characters are asumed to have width of 1 rather than 0 width [1]. This breaks skim's rendering pretty badly unfortunately, mainly by not erasing cells that should be erased, so the output looks garbled. Apparently this change broke other parts of the ecosystem too, such as the (actually-maintained, unlike tuikit) ratatui crate. There's some good discussion in [2] about how fundamentally unicode-width is not intended to be "how wide does this draw in a terminal emulator", despite many people using it that way. Other options should be explored longer term (if I decide to meaningfully pick up maintenance of skim), such as the unicode-display-width crated which is mentioned in [2] but still might not be the right algorithm. I think really the proper fix is to strip control characters within skim (or the TUI library) before doing anything to determine the unicode width. But for now, take the easy way out and just pin the unicode-width version to something below 0.1.13 and forget about it until I have more time to put into caring about improving skim. P.S. Change .width_cjk() to .width() in a couple places for consistency. [1] unicode-rs/unicode-width@3063422 [2] unicode-rs/unicode-width#55
1 parent 9c34879 commit fac04a5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ nix = "0.26"
2525
atty = { version = "0.2.14", optional = true }
2626
regex = "1.6.0"
2727
shlex = { version = "1.1.0", optional = true }
28-
unicode-width = "0.1.9"
28+
unicode-width = "0.1.9, <0.1.13"
2929
log = "0.4.17"
3030
env_logger = { version = "0.10", optional = true }
3131
time = "0.3.13"

src/selection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl Selection {
339339
} else {
340340
let regex = self.skip_to_pattern.as_ref().unwrap();
341341
if let Some(mat) = regex.find(text) {
342-
text[..mat.start()].width_cjk()
342+
text[..mat.start()].width()
343343
} else {
344344
0
345345
}
@@ -512,7 +512,7 @@ impl Selection {
512512
.col(2)
513513
.tabstop(self.tabstop)
514514
.container_width(container_width)
515-
.text_width(display_content.stripped().width_cjk())
515+
.text_width(display_content.stripped().width())
516516
.hscroll_offset(self.hscroll_offset)
517517
.build()
518518
};

0 commit comments

Comments
 (0)