aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-03-07 10:27:53 -0800
committerJoe Wilm <joe@jwilm.com>2017-03-07 10:27:53 -0800
commitb033162d269c8cf3cd23ba7cfb2d67dd58bdf4c2 (patch)
treea5c0ea3714467e6928c1457adbd34b5056c6c4b7
parentad56e3b7615370ab156cd9a5f7876f67b07c80fc (diff)
downloadalacritty-zero-width-chars.tar.gz
alacritty-zero-width-chars.zip
-rw-r--r--src/term/mod.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 4ee685b1..345405ce 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -1036,6 +1036,14 @@ impl ansi::Handler for Term {
/// A character to be displayed
#[inline]
fn input(&mut self, c: char) {
+ // Number of cells the char will occupy
+ //
+ // TODO handle zero width characters (eg unicode variation selectors)
+ let width = match c.width() {
+ Some(0) | None => return,
+ Some(width) => width,
+ };
+
if self.input_needs_wrap {
if !self.mode.contains(mode::LINE_WRAP) {
return;
@@ -1064,9 +1072,6 @@ impl ansi::Handler for Term {
}
{
- // Number of cells the char will occupy
- let width = c.width();
-
// Sigh, borrowck making us check the width twice. Hopefully the
// optimizer can fix it.
{
@@ -1075,24 +1080,26 @@ impl ansi::Handler for Term {
cell.c = self.cursor.charsets[self.active_charset].map(c);
// Handle wide chars
- if let Some(2) = width {
+ if width == 2 {
cell.flags.insert(cell::WIDE_CHAR);
}
}
// Set spacer cell for wide chars.
- if let Some(2) = width {
+ if width == 2 {
+ // Only set the wide char spacer when not at EOL
if self.cursor.point.col + 1 < self.grid.num_cols() {
- self.cursor.point.col += 1;
- let spacer = &mut self.grid[&self.cursor.point];
+ let mut point = self.cursor.point;
+ point.col += 1;
+ let spacer = &mut self.grid[&point];
*spacer = self.cursor.template;
spacer.flags.insert(cell::WIDE_CHAR_SPACER);
}
}
}
- if (self.cursor.point.col + 1) < self.grid.num_cols() {
- self.cursor.point.col += 1;
+ if (self.cursor.point.col + width) < self.grid.num_cols() {
+ self.cursor.point.col += width;
} else {
self.input_needs_wrap = true;
}