Mercurial > vim
diff src/evalfunc.c @ 23600:f4347a61ed38 v8.2.2342
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Commit: https://github.com/vim/vim/commit/9145846b6aa411e3ab5c0d145b37808654352877
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 13 20:08:38 2021 +0100
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Problem: "char" functions return the wront column in Insert mode when the
cursor is beyond the end of the line.
Solution: Compute the column correctly. (Yegappan Lakshmanan, closes #7669)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 13 Jan 2021 20:15:04 +0100 |
parents | a9433f834693 |
children | 7b3317e959e3 |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -2748,7 +2748,7 @@ set_cursorpos(typval_T *argvars, typval_ semsg(_(e_invarg2), tv_get_string(&argvars[0])); col = (long)tv_get_number_chk(&argvars[1], NULL); if (charcol) - col = buf_charidx_to_byteidx(curbuf, line, col); + col = buf_charidx_to_byteidx(curbuf, line, col) + 1; if (argvars[2].v_type != VAR_UNKNOWN) coladd = (long)tv_get_number_chk(&argvars[2], NULL); } @@ -4011,8 +4011,8 @@ getpos_both( if (fp != NULL && charcol) { pos = *fp; - pos.col = buf_byteidx_to_charidx(wp->w_buffer, pos.lnum, - pos.col) - 1; + pos.col = + buf_byteidx_to_charidx(wp->w_buffer, pos.lnum, pos.col); fp = &pos; } }