vim-patch:8.2.1517: cannot easily get the character under the cursor

Problem:    Cannot easily get the character under the cursor.
Solution:   Add the {chars} argument to strpart().
6c53fca023
This commit is contained in:
Jan Edmund Lazo
2020-08-23 18:03:41 -04:00
parent bf8d96a30d
commit 107e50b25e
4 changed files with 32 additions and 10 deletions

View File

@@ -9946,6 +9946,16 @@ static void f_strpart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
len = slen - n;
}
if (argvars[2].v_type != VAR_UNKNOWN && argvars[3].v_type != VAR_UNKNOWN) {
int off;
// length in characters
for (off = n; off < (int)slen && len > 0; len--) {
off += utfc_ptr2len((char_u *)p + off);
}
len = off - n;
}
rettv->v_type = VAR_STRING;
rettv->vval.v_string = (char_u *)xmemdupz(p + n, (size_t)len);
}