summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-15 21:31:52 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-15 21:31:52 +0200
commit9bca58f36d1f6a2ac0e4022caa5f355d39357a05 (patch)
tree768337b62bcf557b17365cbcc4a89859ac73febe /src
parenta4b2699e28a30dcc4d1696b317f24a8904ec2a06 (diff)
downloadvim-git-9bca58f36d1f6a2ac0e4022caa5f355d39357a05.tar.gz
patch 8.1.1849v8.1.1849
Diffstat (limited to 'src')
-rw-r--r--src/evalfunc.c86
-rw-r--r--src/insexpand.c160
-rw-r--r--src/proto/insexpand.pro7
-rw-r--r--src/version.c2
4 files changed, 125 insertions, 130 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 67875fe2b..e7f870c6f 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -75,12 +75,6 @@ static void f_char2nr(typval_T *argvars, typval_T *rettv);
static void f_chdir(typval_T *argvars, typval_T *rettv);
static void f_cindent(typval_T *argvars, typval_T *rettv);
static void f_col(typval_T *argvars, typval_T *rettv);
-#if defined(FEAT_INS_EXPAND)
-static void f_complete(typval_T *argvars, typval_T *rettv);
-static void f_complete_add(typval_T *argvars, typval_T *rettv);
-static void f_complete_check(typval_T *argvars, typval_T *rettv);
-static void f_complete_info(typval_T *argvars, typval_T *rettv);
-#endif
static void f_confirm(typval_T *argvars, typval_T *rettv);
static void f_copy(typval_T *argvars, typval_T *rettv);
#ifdef FEAT_FLOAT
@@ -2294,86 +2288,6 @@ f_col(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = col;
}
-#if defined(FEAT_INS_EXPAND)
-/*
- * "complete()" function
- */
- static void
-f_complete(typval_T *argvars, typval_T *rettv UNUSED)
-{
- int startcol;
-
- if ((State & INSERT) == 0)
- {
- emsg(_("E785: complete() can only be used in Insert mode"));
- return;
- }
-
- /* Check for undo allowed here, because if something was already inserted
- * the line was already saved for undo and this check isn't done. */
- if (!undo_allowed())
- return;
-
- if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
- {
- emsg(_(e_invarg));
- return;
- }
-
- startcol = (int)tv_get_number_chk(&argvars[0], NULL);
- if (startcol <= 0)
- return;
-
- set_completion(startcol - 1, argvars[1].vval.v_list);
-}
-
-/*
- * "complete_add()" function
- */
- static void
-f_complete_add(typval_T *argvars, typval_T *rettv)
-{
- rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0);
-}
-
-/*
- * "complete_check()" function
- */
- static void
-f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
-{
- int saved = RedrawingDisabled;
-
- RedrawingDisabled = 0;
- ins_compl_check_keys(0, TRUE);
- rettv->vval.v_number = ins_compl_interrupted();
- RedrawingDisabled = saved;
-}
-
-/*
- * "complete_info()" function
- */
- static void
-f_complete_info(typval_T *argvars, typval_T *rettv)
-{
- list_T *what_list = NULL;
-
- if (rettv_dict_alloc(rettv) != OK)
- return;
-
- if (argvars[0].v_type != VAR_UNKNOWN)
- {
- if (argvars[0].v_type != VAR_LIST)
- {
- emsg(_(e_listreq));
- return;
- }
- what_list = argvars[0].vval.v_list;
- }
- get_complete_info(what_list, rettv->vval.v_dict);
-}
-#endif
-
/*
* "confirm(message, buttons[, default [, type]])" function
*/
diff --git a/src/insexpand.c b/src/insexpand.c
index 42458005e..136fb67f0 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -859,7 +859,7 @@ completeopt_was_set(void)
* "startcol" is where the matched text starts (1 is first column).
* "list" is the list of matches.
*/
- void
+ static void
set_completion(colnr_T startcol, list_T *list)
{
int save_w_wrow = curwin->w_wrow;
@@ -1522,7 +1522,7 @@ ins_compl_active(void)
/*
* Get complete information
*/
- void
+ static void
get_complete_info(list_T *what_list, dict_T *retdict)
{
int ret = OK;
@@ -2353,6 +2353,55 @@ theend:
#if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) || defined(PROTO)
/*
+ * Add a match to the list of matches from a typeval_T.
+ * If the given string is already in the list of completions, then return
+ * NOTDONE, otherwise add it to the list and return OK. If there is an error,
+ * maybe because alloc() returns NULL, then FAIL is returned.
+ */
+ static int
+ins_compl_add_tv(typval_T *tv, int dir)
+{
+ char_u *word;
+ int dup = FALSE;
+ int empty = FALSE;
+ int flags = 0;
+ char_u *(cptext[CPT_COUNT]);
+
+ if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
+ {
+ word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE);
+ cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict,
+ (char_u *)"abbr", FALSE);
+ cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict,
+ (char_u *)"menu", FALSE);
+ cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict,
+ (char_u *)"kind", FALSE);
+ cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict,
+ (char_u *)"info", FALSE);
+ cptext[CPT_USER_DATA] = dict_get_string(tv->vval.v_dict,
+ (char_u *)"user_data", FALSE);
+ if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL
+ && dict_get_number(tv->vval.v_dict, (char_u *)"icase"))
+ flags |= CP_ICASE;
+ if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
+ dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup");
+ if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL)
+ empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty");
+ if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL
+ && dict_get_number(tv->vval.v_dict, (char_u *)"equal"))
+ flags |= CP_EQUAL;
+ }
+ else
+ {
+ word = tv_get_string_chk(tv);
+ vim_memset(cptext, 0, sizeof(cptext));
+ }
+ if (word == NULL || (!empty && *word == NUL))
+ return FAIL;
+ return ins_compl_add(word, -1, NULL, cptext, dir, flags, dup);
+}
+
+/*
* Add completions from a list.
*/
static void
@@ -2399,52 +2448,81 @@ ins_compl_add_dict(dict_T *dict)
}
/*
- * Add a match to the list of matches from a typeval_T.
- * If the given string is already in the list of completions, then return
- * NOTDONE, otherwise add it to the list and return OK. If there is an error,
- * maybe because alloc() returns NULL, then FAIL is returned.
+ * "complete()" function
*/
- int
-ins_compl_add_tv(typval_T *tv, int dir)
+ void
+f_complete(typval_T *argvars, typval_T *rettv UNUSED)
{
- char_u *word;
- int dup = FALSE;
- int empty = FALSE;
- int flags = 0;
- char_u *(cptext[CPT_COUNT]);
+ int startcol;
- if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
+ if ((State & INSERT) == 0)
{
- word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE);
- cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict,
- (char_u *)"abbr", FALSE);
- cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict,
- (char_u *)"menu", FALSE);
- cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict,
- (char_u *)"kind", FALSE);
- cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict,
- (char_u *)"info", FALSE);
- cptext[CPT_USER_DATA] = dict_get_string(tv->vval.v_dict,
- (char_u *)"user_data", FALSE);
- if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL
- && dict_get_number(tv->vval.v_dict, (char_u *)"icase"))
- flags |= CP_ICASE;
- if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL)
- dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup");
- if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL)
- empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty");
- if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL
- && dict_get_number(tv->vval.v_dict, (char_u *)"equal"))
- flags |= CP_EQUAL;
+ emsg(_("E785: complete() can only be used in Insert mode"));
+ return;
}
- else
+
+ // Check for undo allowed here, because if something was already inserted
+ // the line was already saved for undo and this check isn't done.
+ if (!undo_allowed())
+ return;
+
+ if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL)
{
- word = tv_get_string_chk(tv);
- vim_memset(cptext, 0, sizeof(cptext));
+ emsg(_(e_invarg));
+ return;
}
- if (word == NULL || (!empty && *word == NUL))
- return FAIL;
- return ins_compl_add(word, -1, NULL, cptext, dir, flags, dup);
+
+ startcol = (int)tv_get_number_chk(&argvars[0], NULL);
+ if (startcol <= 0)
+ return;
+
+ set_completion(startcol - 1, argvars[1].vval.v_list);
+}
+
+/*
+ * "complete_add()" function
+ */
+ void
+f_complete_add(typval_T *argvars, typval_T *rettv)
+{
+ rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0);
+}
+
+/*
+ * "complete_check()" function
+ */
+ void
+f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
+{
+ int saved = RedrawingDisabled;
+
+ RedrawingDisabled = 0;
+ ins_compl_check_keys(0, TRUE);
+ rettv->vval.v_number = ins_compl_interrupted();
+ RedrawingDisabled = saved;
+}
+
+/*
+ * "complete_info()" function
+ */
+ void
+f_complete_info(typval_T *argvars, typval_T *rettv)
+{
+ list_T *what_list = NULL;
+
+ if (rettv_dict_alloc(rettv) != OK)
+ return;
+
+ if (argvars[0].v_type != VAR_UNKNOWN)
+ {
+ if (argvars[0].v_type != VAR_LIST)
+ {
+ emsg(_(e_listreq));
+ return;
+ }
+ what_list = argvars[0].vval.v_list;
+ }
+ get_complete_info(what_list, rettv->vval.v_dict);
}
#endif
diff --git a/src/proto/insexpand.pro b/src/proto/insexpand.pro
index 3d6da20e7..90b5a0732 100644
--- a/src/proto/insexpand.pro
+++ b/src/proto/insexpand.pro
@@ -24,14 +24,12 @@ int ins_compl_add_infercase(char_u *str_arg, int len, int icase, char_u *fname,
int ins_compl_has_shown_match(void);
int ins_compl_long_shown_match(void);
void completeopt_was_set(void);
-void set_completion(colnr_T startcol, list_T *list);
int pum_wanted(void);
void ins_compl_show_pum(void);
char_u *find_word_start(char_u *ptr);
char_u *find_word_end(char_u *ptr);
void ins_compl_clear(void);
int ins_compl_active(void);
-void get_complete_info(list_T *what_list, dict_T *retdict);
int ins_compl_used_match(void);
void ins_compl_init_get_longest(void);
int ins_compl_interrupted(void);
@@ -41,7 +39,10 @@ int ins_compl_bs(void);
void ins_compl_addleader(int c);
void ins_compl_addfrommatch(void);
int ins_compl_prep(int c);
-int ins_compl_add_tv(typval_T *tv, int dir);
+void f_complete(typval_T *argvars, typval_T *rettv);
+void f_complete_add(typval_T *argvars, typval_T *rettv);
+void f_complete_check(typval_T *argvars, typval_T *rettv);
+void f_complete_info(typval_T *argvars, typval_T *rettv);
void ins_compl_delete(void);
void ins_compl_insert(int in_compl_func);
void ins_compl_check_keys(int frequency, int in_compl_func);
diff --git a/src/version.c b/src/version.c
index 3ec385cfb..4a993dace 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1849,
+/**/
1848,
/**/
1847,