patch 9.1.1509: patch 9.1.1505 was not good
Problem: Patch 9.1.1505 was not good
Solution: Revert "patch 9.1.1505: not possible to return completion type
for :ex command" and instead add the getcompletiontype()
function (Hirohito Higashi).
related: #17606
closes: #17662
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index f7a5f5c..b1c9ed6 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -4557,6 +4557,35 @@
}
/*
+ * "getcompletiontype()" function
+ */
+ void
+f_getcompletiontype(typval_T *argvars, typval_T *rettv)
+{
+ char_u *pat;
+ expand_T xpc;
+ int cmdline_len;
+
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+
+ if (check_for_string_arg(argvars, 0) == FAIL)
+ return;
+
+ pat = tv_get_string(&argvars[0]);
+ ExpandInit(&xpc);
+
+ cmdline_len = (int)STRLEN(pat);
+ set_cmd_context(&xpc, pat, cmdline_len, cmdline_len, FALSE);
+ xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
+ xpc.xp_col = cmdline_len;
+
+ rettv->vval.v_string = get_cmdline_completion(&xpc);
+
+ ExpandCleanup(&xpc);
+}
+
+/*
* "cmdcomplete_info()" function
*/
void