diff options
author | VanaIgr <vanaigranov@gmail.com> | 2024-02-26 04:12:55 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 18:12:55 +0800 |
commit | ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f (patch) | |
tree | ae35dff22d4f418f040d39acc88206e64ffb1984 /src/nvim/ex_getln.c | |
parent | 8b4e26915612caf2d143edca31919cae18a848a1 (diff) | |
download | rneovim-ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f.tar.gz rneovim-ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f.tar.bz2 rneovim-ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f.zip |
fix(mbyte): fix bugs in utf_cp_*_off() functions
Problems:
- Illegal bytes after valid UTF-8 char cause utf_cp_*_off() to fail.
- When stream isn't NUL-terminated, utf_cp_*_off() may go over the end.
Solution: Don't go over end of the char of end of the string.
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 8af5730ffe..c396bbaae3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1512,8 +1512,8 @@ static int command_line_erase_chars(CommandLineState *s) } if (s->c == K_DEL) { - ccline.cmdpos += mb_off_next(ccline.cmdbuff, - ccline.cmdbuff + ccline.cmdpos); + CharBoundsOff bounds = utf_cp_bounds(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos); + ccline.cmdpos += bounds.begin_off != 0 ? bounds.end_off : 0; } if (ccline.cmdpos > 0) { |