Skip to content

Instantly share code, notes, and snippets.

@ichizok
Created December 2, 2013 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichizok/7755887 to your computer and use it in GitHub Desktop.
Save ichizok/7755887 to your computer and use it in GitHub Desktop.
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -7972,8 +7972,8 @@
{"iconv", 3, 3, f_iconv},
{"indent", 1, 1, f_indent},
{"index", 2, 4, f_index},
- {"input", 1, 3, f_input},
- {"inputdialog", 1, 3, f_inputdialog},
+ {"input", 1, 4, f_input},
+ {"inputdialog", 1, 4, f_inputdialog},
{"inputlist", 1, 1, f_inputlist},
{"inputrestore", 0, 0, f_inputrestore},
{"inputsave", 0, 0, f_inputsave},
@@ -13022,6 +13022,7 @@
char_u *defstr = (char_u *)"";
int xp_type = EXPAND_NOTHING;
char_u *xp_arg = NULL;
+ list_T *ret_list = NULL;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -13060,24 +13061,38 @@
if (defstr != NULL)
stuffReadbuffSpec(defstr);
- if (!inputdialog && argvars[2].v_type != VAR_UNKNOWN)
- {
- char_u *xp_name;
- int xp_namelen;
- long argt;
-
- /* input() with a third argument: completion */
- rettv->vval.v_string = NULL;
-
- xp_name = get_tv_string_buf_chk(&argvars[2], buf);
- if (xp_name == NULL)
- return;
-
- xp_namelen = (int)STRLEN(xp_name);
-
- if (parse_compl_arg(xp_name, xp_namelen, &xp_type, &argt,
- &xp_arg) == FAIL)
- return;
+ if (argvars[2].v_type != VAR_UNKNOWN)
+ {
+ if (argvars[3].v_type == VAR_LIST)
+ {
+ if ((ret_list = argvars[3].vval.v_list) != NULL
+ && tv_check_lock(ret_list->lv_lock,
+ (char_u *)_("add() argument")))
+ ret_list = NULL;
+ }
+
+ if (!inputdialog)
+ {
+ char_u *xp_name;
+ int xp_namelen;
+ long argt;
+
+ /* input() with a third argument: completion */
+ rettv->vval.v_string = NULL;
+
+ xp_name = get_tv_string_buf_chk(&argvars[2], buf);
+ if (xp_name == NULL)
+ return;
+
+ xp_namelen = (int)STRLEN(xp_name);
+
+ if (xp_namelen > 0 || ret_list == NULL)
+ {
+ if (parse_compl_arg(xp_name, xp_namelen, &xp_type, &argt,
+ &xp_arg) == FAIL)
+ return;
+ }
+ }
}
}
@@ -13099,6 +13114,13 @@
&& argvars[2].v_type != VAR_UNKNOWN)
rettv->vval.v_string = vim_strsave(get_tv_string_buf(
&argvars[2], buf));
+ if (ret_list)
+ {
+ if (rettv->vval.v_string)
+ list_append_tv(ret_list, rettv);
+ else
+ list_append_number(ret_list, 0);
+ }
vim_free(xp_arg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment