diff options
author | Ibby <33922797+SleepySwords@users.noreply.github.com> | 2023-04-12 18:21:46 +1000 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-05-22 13:49:42 +0200 |
commit | 5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc (patch) | |
tree | eec2b15afbb46844c718c51c0e4c7c2af7ae00d1 /src/nvim/mbyte.c | |
parent | 7423d3479d95e875e2d261d6e404ad19a631e530 (diff) | |
download | rneovim-5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc.tar.gz rneovim-5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc.tar.bz2 rneovim-5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc.zip |
fix(ui): fix tabs not being spaced properly after virtual text with no wrap
also fixes incorrect skipping of multibyte characters
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 7d61b918d2..66c26275f1 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2024,6 +2024,24 @@ int mb_charlen(const char *str) return count; } +int mb_charlen2bytelen(const char *str, int charlen) +{ + const char *p = str; + int count = 0; + + if (p == NULL) { + return 0; + } + + for (int i = 0; *p != NUL && i < charlen; i++) { + int b = utfc_ptr2len(p); + p += b; + count += b; + } + + return count; +} + /// Like mb_charlen() but for a string with specified length. int mb_charlen_len(const char *str, int len) { |