aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorTony Chen <tchen1998@gmail.com>2020-11-30 08:33:52 -0500
committerchentau <tchen1998@gmail.com>2021-01-26 17:04:32 -0800
commitd95a465b4399c3c10b83925935ec5f4807d65b60 (patch)
tree5a356442adb3cd61483cf0dfb6958731d58b1249 /src/nvim/ex_getln.c
parent901dd79f6a5ee78a55d726abca868bebff117ca9 (diff)
downloadrneovim-d95a465b4399c3c10b83925935ec5f4807d65b60.tar.gz
rneovim-d95a465b4399c3c10b83925935ec5f4807d65b60.tar.bz2
rneovim-d95a465b4399c3c10b83925935ec5f4807d65b60.zip
Don't show entire context when completing
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 96cab0f110..8d10e98259 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3946,6 +3946,12 @@ nextwild (
p2 = ExpandOne(xp, p1, vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
use_options, type);
xfree(p1);
+
+ // xp->xp_pattern might have been modified by ExpandOne (for example,
+ // in lua completion), so recompute the pattern index and length
+ i = (int)(xp->xp_pattern - ccline.cmdbuff);
+ xp->xp_pattern_len = (size_t)ccline.cmdpos - (size_t)i;
+
// Longest match: make sure it is not shorter, happens with :help.
if (p2 != NULL && type == WILD_LONGEST) {
for (j = 0; (size_t)j < xp->xp_pattern_len; j++) {
@@ -3961,7 +3967,7 @@ nextwild (
}
if (p2 != NULL && !got_int) {
- difflen = (int)STRLEN(p2) - (int)xp->xp_pattern_len;
+ difflen = (int)STRLEN(p2) - (int)(xp->xp_pattern_len);
if (ccline.cmdlen + difflen + 4 > ccline.cmdbufflen) {
realloc_cmdbuff(ccline.cmdlen + difflen + 4);
xp->xp_pattern = ccline.cmdbuff + i;
@@ -5109,7 +5115,7 @@ ExpandFromContext (
}
if (xp->xp_context == EXPAND_LUA) {
ILOG("PAT %s", pat);
- return nlua_expand_pat(pat, num_file, file);
+ return nlua_expand_pat(xp, pat, num_file, file);
}
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);