From 9e1c659666b5909b0ebb77406db42bc6892659d6 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 22 Sep 2016 00:58:46 -0400 Subject: [PATCH] vim-patch:7.4.1697 Problem: Display problems when the 'ambiwidth' and 'emoji' options are not set properly or the terminal doesn't behave as expected. Solution: After drawing an ambiguous width character always position the cursor. https://github.com/vim/vim/commit/cb0700844c1274fe8bc0ceaffaee0ad21c406f30 --- src/nvim/mbyte.c | 11 +++++------ src/nvim/ui.c | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 2978171051..c08b9e8fcf 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1724,12 +1724,11 @@ int utf_class(int c) return 2; } -/* - * Code for Unicode case-dependent operations. Based on notes in - * http://www.unicode.org/Public/UNIDATA/CaseFolding.txt - * This code uses simple case folding, not full case folding. - * Last updated for Unicode 5.2. - */ +int utf_ambiguous_width(int c) +{ + return c >= 0x80 && (intable(ambiguous, ARRAY_SIZE(ambiguous), c) + || intable(emoji_all, ARRAY_SIZE(emoji_all), c)); +} /* * Generic conversion function for case operations. diff --git a/src/nvim/ui.c b/src/nvim/ui.c index b8d44cbcf8..648d633e07 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -397,7 +397,10 @@ static void send_output(uint8_t **ptr) size_t clen = (size_t)mb_ptr2len(p); UI_CALL(put, p, (size_t)clen); col++; - if (mb_ptr2cells(p) > 1) { + if (utf_ambiguous_width(*p)) { + pending_cursor_update = true; + flush_cursor_update(); + } else if (mb_ptr2cells(p) > 1) { // double cell character, blank the next cell UI_CALL(put, NULL, 0); col++;