diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2021-11-21 22:47:29 -0700 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-01-11 14:31:07 -0700 |
commit | 3a020dd3737d55a69f93788dabc8d2d2d1ba9413 (patch) | |
tree | 90192e6416ea4a083894357831eaad2a78e53856 | |
parent | c68d3f83ecb7424379673acf61d7045c13effbd4 (diff) | |
download | rneovim-3a020dd3737d55a69f93788dabc8d2d2d1ba9413.tar.gz rneovim-3a020dd3737d55a69f93788dabc8d2d2d1ba9413.tar.bz2 rneovim-3a020dd3737d55a69f93788dabc8d2d2d1ba9413.zip |
Enable multibyte registers in VimL.
This allows users to execute commands like:
let @λ = 'new register content.'
-rw-r--r-- | src/nvim/eval.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a1c832bca5..80aa3a3433 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1616,7 +1616,7 @@ static const char_u *skip_var_list(const char_u *arg, int *var_count, int *semic static const char_u *skip_var_one(const char_u *arg) { if (*arg == '@' && arg[1] != NUL) { - return arg + 2; + return arg + 1 + utfc_ptr2len(arg + 1); } return find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); @@ -1939,10 +1939,13 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons return NULL; } arg++; + int regname = utf_ptr2char(arg); + int mblen = utf_ptr2len(arg); + if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) { semsg(_(e_letwrong), op); } else if (endchars != NULL - && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) { + && vim_strchr(endchars, *skipwhite(arg + mblen)) == NULL) { emsg(_(e_letunexp)); } else { char_u *s; @@ -1950,7 +1953,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons char_u *ptofree = NULL; const char *p = tv_get_string_chk(tv); if (p != NULL && op != NULL && *op == '.') { - s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc); + s = get_reg_contents(regname == '@' ? '"' : regname, kGRegExprSrc); if (s != NULL) { ptofree = concat_str(s, (const char_u *)p); p = (const char *)ptofree; @@ -1958,9 +1961,9 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv, const bool copy, cons } } if (p != NULL) { - write_reg_contents(*arg == '@' ? '"' : *arg, + write_reg_contents(regname == '@' ? '"' : regname, (const char_u *)p, STRLEN(p), false); - arg_end = arg + 1; + arg_end = arg + mblen; } xfree(ptofree); } @@ -4218,13 +4221,14 @@ static int eval7(char_u **arg, typval_T *rettv, int evaluate, int want_string) // Register contents: @r. case '@': ++*arg; + int regname = mb_cptr2char_adv((const char_u**) arg); if (evaluate) { rettv->v_type = VAR_STRING; - rettv->vval.v_string = get_reg_contents(**arg, kGRegExprSrc); - } - if (**arg != NUL) { - ++*arg; + rettv->vval.v_string = get_reg_contents(regname, kGRegExprSrc); } + // if (**arg != NUL) { + // ++*arg; + // } break; // nested expression: (expression). |