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.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 7ab07fe6a2..124d6acfe9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -8728,10 +8728,10 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
fold_count = foldedCount(curwin, lnum, &foldinfo);
if (fold_count > 0) {
- text = get_foldtext(curwin, lnum, lnum + fold_count - 1,
- &foldinfo, buf);
- if (text == buf)
+ text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf);
+ if (text == buf) {
text = vim_strsave(text);
+ }
rettv->vval.v_string = text;
}
}
@@ -13416,14 +13416,12 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
q = (char *)path_tail((char_u *)p);
}
if (q > p && !path_is_absolute_path((const char_u *)buf)) {
- // Symlink is relative to directory of argument.
+ // Symlink is relative to directory of argument. Replace the
+ // symlink with the resolved name in the same directory.
const size_t p_len = strlen(p);
const size_t buf_len = strlen(buf);
- cpy = xmalloc(p_len + buf_len + 1);
- memcpy(cpy, p, p_len);
- memcpy(path_tail((char_u *)cpy), buf, buf_len + 1);
- xfree(p);
- p = cpy;
+ p = xrealloc(p, p_len + buf_len + 1);
+ memcpy(path_tail((char_u *)p), buf, buf_len + 1);
} else {
xfree(p);
p = xstrdup(buf);
@@ -16438,7 +16436,12 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return;
}
- (void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern);
+ const char *fname = NULL;
+ if (argvars[1].v_type != VAR_UNKNOWN) {
+ fname = tv_get_string(&argvars[1]);
+ }
+ (void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern,
+ (char_u *)fname);
}
/*