diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mbyte.c | 49 | ||||
-rw-r--r-- | src/nvim/normal.c | 4 |
2 files changed, 30 insertions, 23 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 683087bd7b..e7579399f3 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -456,43 +456,50 @@ static bool intable(const struct interval *table, size_t n_items, int c) return false; } -/* - * For UTF-8 character "c" return 2 for a double-width character, 1 for others. - * Returns 4 or 6 for an unprintable character. - * Is only correct for characters >= 0x80. - * When p_ambw is "double", return 2 for a character with East Asian Width - * class 'A'(mbiguous). - */ +/// For UTF-8 character "c" return 2 for a double-width character, 1 for others. +/// Returns 4 or 6 for an unprintable character. +/// Is only correct for characters >= 0x80. +/// When p_ambw is "double", return 2 for a character with East Asian Width +/// class 'A'(mbiguous). +/// +/// @note Tables `doublewidth` and `ambiguous` are generated by +/// gen_unicode_tables.lua, which must be manually invoked as needed. int utf_char2cells(int c) { if (c >= 0x100) { #ifdef USE_WCHAR_FUNCTIONS - /* - * Assume the library function wcwidth() works better than our own - * stuff. It should return 1 for ambiguous width chars! - */ + // + // Assume the library function wcwidth() works better than our own + // stuff. It should return 1 for ambiguous width chars! + // int n = wcwidth(c); - if (n < 0) - return 6; /* unprintable, displays <xxxx> */ - if (n > 1) + if (n < 0) { + return 6; // unprintable, displays <xxxx> + } + if (n > 1) { return n; + } #else - if (!utf_printable(c)) - return 6; /* unprintable, displays <xxxx> */ - if (intable(doublewidth, ARRAY_SIZE(doublewidth), c)) + if (!utf_printable(c)) { + return 6; // unprintable, displays <xxxx> + } + if (intable(doublewidth, ARRAY_SIZE(doublewidth), c)) { return 2; + } #endif if (p_emoji && intable(emoji_width, ARRAY_SIZE(emoji_width), c)) { return 2; } + } else if (c >= 0x80 && !vim_isprintc(c)) { + // Characters below 0x100 are influenced by 'isprint' option. + return 4; // unprintable, displays <xx> } - /* Characters below 0x100 are influenced by 'isprint' option */ - else if (c >= 0x80 && !vim_isprintc(c)) - return 4; /* unprintable, displays <xx> */ - if (c >= 0x80 && *p_ambw == 'd' && intable(ambiguous, ARRAY_SIZE(ambiguous), c)) + if (c >= 0x80 && *p_ambw == 'd' + && intable(ambiguous, ARRAY_SIZE(ambiguous), c)) { return 2; + } return 1; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index af2d24e9db..0a4d32d438 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7987,8 +7987,8 @@ static void nv_event(cmdarg_T *cap) multiqueue_process_events(main_loop.events); finish_op = false; if (may_restart) { - // Tricky: if restart_edit was set before the handler we are in ctrl-o mode - // but if not, the event should be allow to trigger :startinsert + // Tricky: if restart_edit was set before the handler we are in ctrl-o mode, + // but if not, the event should be allowed to trigger :startinsert. cap->retval |= CA_COMMAND_BUSY; // don't call edit() now } } |