mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
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.
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user