aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index d058e6ccae..116944b28d 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -2580,10 +2580,10 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx)
} else if (c == '=') {
got_eq = TRUE;
xp->xp_context = EXPAND_EXPRESSION;
- } else if (c == '<'
+ } else if ((c == '<' || c == '#')
&& xp->xp_context == EXPAND_FUNCTIONS
&& vim_strchr(xp->xp_pattern, '(') == NULL) {
- /* Function name can start with "<SNR>" */
+ /* Function name can start with "<SNR>" and contain '#'. */
break;
} else if (cmdidx != CMD_let || got_eq) {
if (c == '"') { /* string */
@@ -9553,6 +9553,9 @@ static void f_getreg(typval_T *argvars, typval_T *rettv)
rettv->v_type = VAR_LIST;
rettv->vval.v_list =
get_reg_contents(regname, (arg2 ? kGRegExprSrc : 0) | kGRegList);
+ if (rettv->vval.v_list != NULL) {
+ rettv->vval.v_list->lv_refcount++;
+ }
} else {
rettv->v_type = VAR_STRING;
rettv->vval.v_string = get_reg_contents(regname, arg2 ? kGRegExprSrc : 0);
@@ -15247,23 +15250,38 @@ static void f_winrestview(typval_T *argvars, typval_T *rettv)
|| (dict = argvars[0].vval.v_dict) == NULL)
EMSG(_(e_invarg));
else {
- curwin->w_cursor.lnum = get_dict_number(dict, (char_u *)"lnum");
- curwin->w_cursor.col = get_dict_number(dict, (char_u *)"col");
- curwin->w_cursor.coladd = get_dict_number(dict, (char_u *)"coladd");
- curwin->w_curswant = get_dict_number(dict, (char_u *)"curswant");
- curwin->w_set_curswant = FALSE;
-
- set_topline(curwin, get_dict_number(dict, (char_u *)"topline"));
- curwin->w_topfill = get_dict_number(dict, (char_u *)"topfill");
- curwin->w_leftcol = get_dict_number(dict, (char_u *)"leftcol");
- curwin->w_skipcol = get_dict_number(dict, (char_u *)"skipcol");
+ if (dict_find(dict, (char_u *)"lnum", -1) != NULL) {
+ curwin->w_cursor.lnum = get_dict_number(dict, (char_u *)"lnum");
+ }
+ if (dict_find(dict, (char_u *)"col", -1) != NULL) {
+ curwin->w_cursor.col = get_dict_number(dict, (char_u *)"col");
+ }
+ if (dict_find(dict, (char_u *)"coladd", -1) != NULL) {
+ curwin->w_cursor.coladd = get_dict_number(dict, (char_u *)"coladd");
+ }
+ if (dict_find(dict, (char_u *)"curswant", -1) != NULL) {
+ curwin->w_curswant = get_dict_number(dict, (char_u *)"curswant");
+ curwin->w_set_curswant = FALSE;
+ }
+ if (dict_find(dict, (char_u *)"topline", -1) != NULL) {
+ set_topline(curwin, get_dict_number(dict, (char_u *)"topline"));
+ }
+ if (dict_find(dict, (char_u *)"topfill", -1) != NULL) {
+ curwin->w_topfill = get_dict_number(dict, (char_u *)"topfill");
+ }
+ if (dict_find(dict, (char_u *)"leftcol", -1) != NULL) {
+ curwin->w_leftcol = get_dict_number(dict, (char_u *)"leftcol");
+ }
+ if (dict_find(dict, (char_u *)"skipcol", -1) != NULL) {
+ curwin->w_skipcol = get_dict_number(dict, (char_u *)"skipcol");
+ }
check_cursor();
win_new_height(curwin, curwin->w_height);
win_new_width(curwin, curwin->w_width);
changed_window_setting();
- if (curwin->w_topline == 0)
+ if (curwin->w_topline <= 0)
curwin->w_topline = 1;
if (curwin->w_topline > curbuf->b_ml.ml_line_count)
curwin->w_topline = curbuf->b_ml.ml_line_count;
@@ -19650,6 +19668,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
regmatch_T regmatch;
int do_all;
char_u *tail;
+ char_u *end;
garray_T ga;
char_u *save_cpo;
char_u *zero_width = NULL;
@@ -19666,6 +19685,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) {
tail = str;
+ end = str + STRLEN(str);
while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str))) {
/* Skip empty match except for first match. */
if (regmatch.startp[0] == regmatch.endp[0]) {
@@ -19688,7 +19708,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
* - The text after the match.
*/
sublen = vim_regsub(&regmatch, sub, tail, FALSE, TRUE, FALSE);
- ga_grow(&ga, (int)(STRLEN(tail) + sublen -
+ ga_grow(&ga, (int)((end - tail) + sublen -
(regmatch.endp[0] - regmatch.startp[0])));
/* copy the text up to where the match is */