diff --git a/kitty/screen.c b/kitty/screen.c index fad5429fb..0ee56481e 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -373,6 +373,19 @@ draw_combining_char(Screen *self, char_type ch) { if (xpos == self->columns - 1) move_widened_char(self, cpu_cell, gpu_cell, xpos, ypos); else self->cursor->x++; } + } else if (ch == 0xfe0e) { + CPUCell *cpu_cell = self->linebuf->line->cpu_cells + xpos; + GPUCell *gpu_cell = self->linebuf->line->gpu_cells + xpos; + if ((gpu_cell->attrs & WIDTH_MASK) == 0 && cpu_cell->ch == 0 && xpos > 0) { + xpos--; + if (self->cursor->x > 0) self->cursor->x--; + cpu_cell = self->linebuf->line->cpu_cells + xpos; + gpu_cell = self->linebuf->line->gpu_cells + xpos; + } + + if ((gpu_cell->attrs & WIDTH_MASK) == 2 && cpu_cell->cc_idx[0] == VS15 && is_emoji_presentation_base(cpu_cell->ch)) { + gpu_cell->attrs = (gpu_cell->attrs & !WIDTH_MASK) | 1; + } } } } diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index 9b31da3d0..5055fca72 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -429,6 +429,20 @@ class TestScreen(BaseTest): s.scroll(2, True) self.ae(s.text_for_selection(), expected) + def test_variation_selectors(self): + s = self.create_screen() + s.draw('\U0001f610') + self.ae(s.cursor.x, 2) + s.carriage_return(), s.linefeed() + s.draw('\U0001f610\ufe0e') + self.ae(s.cursor.x, 1) + s.carriage_return(), s.linefeed() + s.draw('\u25b6') + self.ae(s.cursor.x, 1) + s.carriage_return(), s.linefeed() + s.draw('\u25b6\ufe0f') + self.ae(s.cursor.x, 2) + def test_serialize(self): s = self.create_screen() s.draw('ab' * s.columns)