summaryrefslogtreecommitdiffstats
path: root/src/paint.rs
diff options
context:
space:
mode:
authorWang Xuerui <git@xen0n.name>2019-11-14 11:48:30 +0800
committerWang Xuerui <git@xen0n.name>2019-11-14 11:48:32 +0800
commitb9ed24d34fa7d69abcc8169441c5649463915013 (patch)
tree24c1edfed1364ec641ae49942d510c3e0d48a27b /src/paint.rs
parent0052bd7b170188ec30fd1beb5ed89b51c8efbd70 (diff)
Properly calculate string widths with unicode_width
Fixes diffs rendering with lines containing CJK characters.
Diffstat (limited to 'src/paint.rs')
-rw-r--r--src/paint.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/paint.rs b/src/paint.rs
index d291417a..ac705b91 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -3,7 +3,7 @@ use std::io::Write;
use syntect::easy::HighlightLines;
use syntect::highlighting::{Style, StyleModifier};
use syntect::parsing::{SyntaxReference, SyntaxSet};
-use unicode_segmentation::UnicodeSegmentation;
+use unicode_width::UnicodeWidthStr;
use crate::bat::assets::HighlightingAssets;
use crate::config;
@@ -110,7 +110,7 @@ impl<'a> Painter<'a> {
for (style, text) in superimpose_style_sections(syntax_sections, diff_sections) {
paint_text(&text, style, output_buffer).unwrap();
if config.width.is_some() {
- text_width += text.graphemes(true).count();
+ text_width += UnicodeWidthStr::width(text.as_str());
}
}
if should_trim_newline_and_right_pad {