Mercurial > vim
comparison src/edit.c @ 13210:c1534eb682a6 v8.0.1479
patch 8.0.1479: insert mode completion state is confusing
commit https://github.com/vim/vim/commit/bc0e9adae9c253f36803665180e4b576d1e725ab
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 9 12:13:34 2018 +0100
patch 8.0.1479: insert mode completion state is confusing
Problem: Insert mode completion state is confusing.
Solution: Move ctrl_x_mode into edit.c. Add CTRL_X_NORMAL for zero.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 09 Feb 2018 12:15:05 +0100 |
parents | 808625d4b71b |
children | ed51483e9971 |
comparison
equal
deleted
inserted
replaced
13209:f3e7d314d8d8 | 13210:c1534eb682a6 |
---|---|
15 | 15 |
16 #ifdef FEAT_INS_EXPAND | 16 #ifdef FEAT_INS_EXPAND |
17 /* | 17 /* |
18 * definitions used for CTRL-X submode | 18 * definitions used for CTRL-X submode |
19 */ | 19 */ |
20 #define CTRL_X_WANT_IDENT 0x100 | 20 # define CTRL_X_WANT_IDENT 0x100 |
21 | 21 |
22 #define CTRL_X_NOT_DEFINED_YET 1 | 22 # define CTRL_X_NORMAL 0 /* CTRL-N CTRL-P completion, default */ |
23 #define CTRL_X_SCROLL 2 | 23 # define CTRL_X_NOT_DEFINED_YET 1 |
24 #define CTRL_X_WHOLE_LINE 3 | 24 # define CTRL_X_SCROLL 2 |
25 #define CTRL_X_FILES 4 | 25 # define CTRL_X_WHOLE_LINE 3 |
26 #define CTRL_X_TAGS (5 + CTRL_X_WANT_IDENT) | 26 # define CTRL_X_FILES 4 |
27 #define CTRL_X_PATH_PATTERNS (6 + CTRL_X_WANT_IDENT) | 27 # define CTRL_X_TAGS (5 + CTRL_X_WANT_IDENT) |
28 #define CTRL_X_PATH_DEFINES (7 + CTRL_X_WANT_IDENT) | 28 # define CTRL_X_PATH_PATTERNS (6 + CTRL_X_WANT_IDENT) |
29 #define CTRL_X_FINISHED 8 | 29 # define CTRL_X_PATH_DEFINES (7 + CTRL_X_WANT_IDENT) |
30 #define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT) | 30 # define CTRL_X_FINISHED 8 |
31 #define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT) | 31 # define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT) |
32 #define CTRL_X_CMDLINE 11 | 32 # define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT) |
33 #define CTRL_X_FUNCTION 12 | 33 # define CTRL_X_CMDLINE 11 |
34 #define CTRL_X_OMNI 13 | 34 # define CTRL_X_FUNCTION 12 |
35 #define CTRL_X_SPELL 14 | 35 # define CTRL_X_OMNI 13 |
36 #define CTRL_X_LOCAL_MSG 15 /* only used in "ctrl_x_msgs" */ | 36 # define CTRL_X_SPELL 14 |
37 #define CTRL_X_EVAL 16 /* for builtin function complete() */ | 37 # define CTRL_X_LOCAL_MSG 15 /* only used in "ctrl_x_msgs" */ |
38 | 38 # define CTRL_X_EVAL 16 /* for builtin function complete() */ |
39 #define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT] | 39 |
40 #define CTRL_X_MODE_LINE_OR_EVAL(m) (m == CTRL_X_WHOLE_LINE || m == CTRL_X_EVAL) | 40 # define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT] |
41 | 41 # define CTRL_X_MODE_LINE_OR_EVAL(m) ((m) == CTRL_X_WHOLE_LINE || (m) == CTRL_X_EVAL) |
42 | |
43 /* Message for CTRL-X mode, index is ctrl_x_mode. */ | |
42 static char *ctrl_x_msgs[] = | 44 static char *ctrl_x_msgs[] = |
43 { | 45 { |
44 N_(" Keyword completion (^N^P)"), /* ctrl_x_mode == 0, ^P/^N compl. */ | 46 N_(" Keyword completion (^N^P)"), /* CTRL_X_NORMAL, ^P/^N compl. */ |
45 N_(" ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)"), | 47 N_(" ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)"), |
46 NULL, | 48 NULL, /* CTRL_X_SCROLL: depends on state */ |
47 N_(" Whole line completion (^L^N^P)"), | 49 N_(" Whole line completion (^L^N^P)"), |
48 N_(" File name completion (^F^N^P)"), | 50 N_(" File name completion (^F^N^P)"), |
49 N_(" Tag completion (^]^N^P)"), | 51 N_(" Tag completion (^]^N^P)"), |
50 N_(" Path pattern completion (^N^P)"), | 52 N_(" Path pattern completion (^N^P)"), |
51 N_(" Definition completion (^D^N^P)"), | 53 N_(" Definition completion (^D^N^P)"), |
52 NULL, | 54 NULL, /* CTRL_X_FINISHED */ |
53 N_(" Dictionary completion (^K^N^P)"), | 55 N_(" Dictionary completion (^K^N^P)"), |
54 N_(" Thesaurus completion (^T^N^P)"), | 56 N_(" Thesaurus completion (^T^N^P)"), |
55 N_(" Command-line completion (^V^N^P)"), | 57 N_(" Command-line completion (^V^N^P)"), |
56 N_(" User defined completion (^U^N^P)"), | 58 N_(" User defined completion (^U^N^P)"), |
57 N_(" Omni completion (^O^N^P)"), | 59 N_(" Omni completion (^O^N^P)"), |
59 N_(" Keyword Local completion (^N^P)"), | 61 N_(" Keyword Local completion (^N^P)"), |
60 NULL, /* CTRL_X_EVAL doesn't use msg. */ | 62 NULL, /* CTRL_X_EVAL doesn't use msg. */ |
61 }; | 63 }; |
62 | 64 |
63 static char e_hitend[] = N_("Hit end of paragraph"); | 65 static char e_hitend[] = N_("Hit end of paragraph"); |
64 #ifdef FEAT_COMPL_FUNC | 66 # ifdef FEAT_COMPL_FUNC |
65 static char e_complwin[] = N_("E839: Completion function changed window"); | 67 static char e_complwin[] = N_("E839: Completion function changed window"); |
66 static char e_compldel[] = N_("E840: Completion function deleted text"); | 68 static char e_compldel[] = N_("E840: Completion function deleted text"); |
67 #endif | 69 # endif |
68 | 70 |
69 /* | 71 /* |
70 * Structure used to store one match for insert completion. | 72 * Structure used to store one match for insert completion. |
71 */ | 73 */ |
72 typedef struct compl_S compl_T; | 74 typedef struct compl_S compl_T; |
81 * cp_flags has FREE_FNAME */ | 83 * cp_flags has FREE_FNAME */ |
82 int cp_flags; /* ORIGINAL_TEXT, CONT_S_IPOS or FREE_FNAME */ | 84 int cp_flags; /* ORIGINAL_TEXT, CONT_S_IPOS or FREE_FNAME */ |
83 int cp_number; /* sequence number */ | 85 int cp_number; /* sequence number */ |
84 }; | 86 }; |
85 | 87 |
86 #define ORIGINAL_TEXT (1) /* the original text when the expansion begun */ | 88 # define ORIGINAL_TEXT (1) /* the original text when the expansion begun */ |
87 #define FREE_FNAME (2) | 89 # define FREE_FNAME (2) |
88 | 90 |
89 /* | 91 /* |
90 * All the current matches are stored in a list. | 92 * All the current matches are stored in a list. |
91 * "compl_first_match" points to the start of the list. | 93 * "compl_first_match" points to the start of the list. |
92 * "compl_curr_match" points to the currently selected entry. | 94 * "compl_curr_match" points to the currently selected entry. |
124 static int compl_restarting = FALSE; /* don't insert match */ | 126 static int compl_restarting = FALSE; /* don't insert match */ |
125 | 127 |
126 /* When the first completion is done "compl_started" is set. When it's | 128 /* When the first completion is done "compl_started" is set. When it's |
127 * FALSE the word to be completed must be located. */ | 129 * FALSE the word to be completed must be located. */ |
128 static int compl_started = FALSE; | 130 static int compl_started = FALSE; |
131 | |
132 /* Which Ctrl-X mode are we in? */ | |
133 static int ctrl_x_mode = CTRL_X_NORMAL; | |
129 | 134 |
130 /* Set when doing something for completion that may call edit() recursively, | 135 /* Set when doing something for completion that may call edit() recursively, |
131 * which is not allowed. */ | 136 * which is not allowed. */ |
132 static int compl_busy = FALSE; | 137 static int compl_busy = FALSE; |
133 | 138 |
172 static void ins_compl_set_original_text(char_u *str); | 177 static void ins_compl_set_original_text(char_u *str); |
173 static void ins_compl_addfrommatch(void); | 178 static void ins_compl_addfrommatch(void); |
174 static int ins_compl_prep(int c); | 179 static int ins_compl_prep(int c); |
175 static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg); | 180 static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg); |
176 static buf_T *ins_compl_next_buf(buf_T *buf, int flag); | 181 static buf_T *ins_compl_next_buf(buf_T *buf, int flag); |
177 #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) | 182 # if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) |
178 static void ins_compl_add_list(list_T *list); | 183 static void ins_compl_add_list(list_T *list); |
179 static void ins_compl_add_dict(dict_T *dict); | 184 static void ins_compl_add_dict(dict_T *dict); |
180 #endif | 185 # endif |
181 static int ins_compl_get_exp(pos_T *ini); | 186 static int ins_compl_get_exp(pos_T *ini); |
182 static void ins_compl_delete(void); | 187 static void ins_compl_delete(void); |
183 static void ins_compl_insert(int in_compl_func); | 188 static void ins_compl_insert(int in_compl_func); |
184 static int ins_compl_next(int allow_get_expansion, int count, int insert_match, int in_compl_func); | 189 static int ins_compl_next(int allow_get_expansion, int count, int insert_match, int in_compl_func); |
185 static int ins_compl_key2dir(int c); | 190 static int ins_compl_key2dir(int c); |
2240 showmode(); | 2245 showmode(); |
2241 } | 2246 } |
2242 } | 2247 } |
2243 | 2248 |
2244 /* | 2249 /* |
2250 * Whether other than default completion has been selected. | |
2251 */ | |
2252 int | |
2253 ctrl_x_mode_not_default(void) | |
2254 { | |
2255 return ctrl_x_mode != CTRL_X_NORMAL; | |
2256 } | |
2257 | |
2258 /* | |
2259 * Whether CTRL-X was typed without a following character. | |
2260 */ | |
2261 int | |
2262 ctrl_x_mode_not_defined_yet(void) | |
2263 { | |
2264 return ctrl_x_mode == CTRL_X_NOT_DEFINED_YET; | |
2265 } | |
2266 | |
2267 /* | |
2245 * Return TRUE if the 'dict' or 'tsr' option can be used. | 2268 * Return TRUE if the 'dict' or 'tsr' option can be used. |
2246 */ | 2269 */ |
2247 static int | 2270 static int |
2248 has_compl_option(int dict_opt) | 2271 has_compl_option(int dict_opt) |
2249 { | 2272 { |
2252 && !curwin->w_p_spell | 2275 && !curwin->w_p_spell |
2253 # endif | 2276 # endif |
2254 ) | 2277 ) |
2255 : (*curbuf->b_p_tsr == NUL && *p_tsr == NUL)) | 2278 : (*curbuf->b_p_tsr == NUL && *p_tsr == NUL)) |
2256 { | 2279 { |
2257 ctrl_x_mode = 0; | 2280 ctrl_x_mode = CTRL_X_NORMAL; |
2258 edit_submode = NULL; | 2281 edit_submode = NULL; |
2259 msg_attr(dict_opt ? (char_u *)_("'dictionary' option is empty") | 2282 msg_attr(dict_opt ? (char_u *)_("'dictionary' option is empty") |
2260 : (char_u *)_("'thesaurus' option is empty"), | 2283 : (char_u *)_("'thesaurus' option is empty"), |
2261 HL_ATTR(HLF_E)); | 2284 HL_ATTR(HLF_E)); |
2262 if (emsg_silent == 0) | 2285 if (emsg_silent == 0) |
2828 { | 2851 { |
2829 int save_w_wrow = curwin->w_wrow; | 2852 int save_w_wrow = curwin->w_wrow; |
2830 int save_w_leftcol = curwin->w_leftcol; | 2853 int save_w_leftcol = curwin->w_leftcol; |
2831 | 2854 |
2832 /* If already doing completions stop it. */ | 2855 /* If already doing completions stop it. */ |
2833 if (ctrl_x_mode != 0) | 2856 if (ctrl_x_mode != CTRL_X_NORMAL) |
2834 ins_compl_prep(' '); | 2857 ins_compl_prep(' '); |
2835 ins_compl_clear(); | 2858 ins_compl_clear(); |
2836 ins_compl_free(); | 2859 ins_compl_free(); |
2837 | 2860 |
2838 compl_direction = FORWARD; | 2861 compl_direction = FORWARD; |
3734 || c == K_MOUSELEFT || c == K_MOUSERIGHT) | 3757 || c == K_MOUSELEFT || c == K_MOUSERIGHT) |
3735 return retval; | 3758 return retval; |
3736 | 3759 |
3737 /* Set "compl_get_longest" when finding the first matches. */ | 3760 /* Set "compl_get_longest" when finding the first matches. */ |
3738 if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET | 3761 if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET |
3739 || (ctrl_x_mode == 0 && !compl_started)) | 3762 || (ctrl_x_mode == CTRL_X_NORMAL && !compl_started)) |
3740 { | 3763 { |
3741 compl_get_longest = (strstr((char *)p_cot, "longest") != NULL); | 3764 compl_get_longest = (strstr((char *)p_cot, "longest") != NULL); |
3742 compl_used_match = TRUE; | 3765 compl_used_match = TRUE; |
3743 | 3766 |
3744 } | 3767 } |
3839 if (compl_cont_mode != 0) | 3862 if (compl_cont_mode != 0) |
3840 compl_cont_status = 0; | 3863 compl_cont_status = 0; |
3841 else | 3864 else |
3842 compl_cont_mode = CTRL_X_NOT_DEFINED_YET; | 3865 compl_cont_mode = CTRL_X_NOT_DEFINED_YET; |
3843 } | 3866 } |
3844 ctrl_x_mode = 0; | 3867 ctrl_x_mode = CTRL_X_NORMAL; |
3845 edit_submode = NULL; | 3868 edit_submode = NULL; |
3846 showmode(); | 3869 showmode(); |
3847 break; | 3870 break; |
3848 } | 3871 } |
3849 } | 3872 } |
3850 else if (ctrl_x_mode != 0) | 3873 else if (ctrl_x_mode != CTRL_X_NORMAL) |
3851 { | 3874 { |
3852 /* We're already in CTRL-X mode, do we stay in it? */ | 3875 /* We're already in CTRL-X mode, do we stay in it? */ |
3853 if (!vim_is_ctrl_x_key(c)) | 3876 if (!vim_is_ctrl_x_key(c)) |
3854 { | 3877 { |
3855 if (ctrl_x_mode == CTRL_X_SCROLL) | 3878 if (ctrl_x_mode == CTRL_X_SCROLL) |
3856 ctrl_x_mode = 0; | 3879 ctrl_x_mode = CTRL_X_NORMAL; |
3857 else | 3880 else |
3858 ctrl_x_mode = CTRL_X_FINISHED; | 3881 ctrl_x_mode = CTRL_X_FINISHED; |
3859 edit_submode = NULL; | 3882 edit_submode = NULL; |
3860 } | 3883 } |
3861 showmode(); | 3884 showmode(); |
3865 { | 3888 { |
3866 /* Show error message from attempted keyword completion (probably | 3889 /* Show error message from attempted keyword completion (probably |
3867 * 'Pattern not found') until another key is hit, then go back to | 3890 * 'Pattern not found') until another key is hit, then go back to |
3868 * showing what mode we are in. */ | 3891 * showing what mode we are in. */ |
3869 showmode(); | 3892 showmode(); |
3870 if ((ctrl_x_mode == 0 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_R | 3893 if ((ctrl_x_mode == CTRL_X_NORMAL && c != Ctrl_N && c != Ctrl_P |
3871 && !ins_compl_pum_key(c)) | 3894 && c != Ctrl_R && !ins_compl_pum_key(c)) |
3872 || ctrl_x_mode == CTRL_X_FINISHED) | 3895 || ctrl_x_mode == CTRL_X_FINISHED) |
3873 { | 3896 { |
3874 /* Get here when we have finished typing a sequence of ^N and | 3897 /* Get here when we have finished typing a sequence of ^N and |
3875 * ^P or other completion characters in CTRL-X mode. Free up | 3898 * ^P or other completion characters in CTRL-X mode. Free up |
3876 * memory that was used, and make sure we can redo the insert. */ | 3899 * memory that was used, and make sure we can redo the insert. */ |
3949 ins_compl_free(); | 3972 ins_compl_free(); |
3950 compl_started = FALSE; | 3973 compl_started = FALSE; |
3951 compl_matches = 0; | 3974 compl_matches = 0; |
3952 if (!shortmess(SHM_COMPLETIONMENU)) | 3975 if (!shortmess(SHM_COMPLETIONMENU)) |
3953 msg_clr_cmdline(); /* necessary for "noshowmode" */ | 3976 msg_clr_cmdline(); /* necessary for "noshowmode" */ |
3954 ctrl_x_mode = 0; | 3977 ctrl_x_mode = CTRL_X_NORMAL; |
3955 compl_enter_selects = FALSE; | 3978 compl_enter_selects = FALSE; |
3956 if (edit_submode != NULL) | 3979 if (edit_submode != NULL) |
3957 { | 3980 { |
3958 edit_submode = NULL; | 3981 edit_submode = NULL; |
3959 showmode(); | 3982 showmode(); |
4290 set_match_pos = FALSE; | 4313 set_match_pos = FALSE; |
4291 | 4314 |
4292 /* For ^N/^P pick a new entry from e_cpt if compl_started is off, | 4315 /* For ^N/^P pick a new entry from e_cpt if compl_started is off, |
4293 * or if found_all says this entry is done. For ^X^L only use the | 4316 * or if found_all says this entry is done. For ^X^L only use the |
4294 * entries from 'complete' that look in loaded buffers. */ | 4317 * entries from 'complete' that look in loaded buffers. */ |
4295 if ((ctrl_x_mode == 0 || CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | 4318 if ((ctrl_x_mode == CTRL_X_NORMAL |
4319 || CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | |
4296 && (!compl_started || found_all)) | 4320 && (!compl_started || found_all)) |
4297 { | 4321 { |
4298 found_all = FALSE; | 4322 found_all = FALSE; |
4299 while (*e_cpt == ',' || *e_cpt == ' ') | 4323 while (*e_cpt == ',' || *e_cpt == ' ') |
4300 e_cpt++; | 4324 e_cpt++; |
4302 { | 4326 { |
4303 ins_buf = curbuf; | 4327 ins_buf = curbuf; |
4304 first_match_pos = *ini; | 4328 first_match_pos = *ini; |
4305 /* Move the cursor back one character so that ^N can match the | 4329 /* Move the cursor back one character so that ^N can match the |
4306 * word immediately after the cursor. */ | 4330 * word immediately after the cursor. */ |
4307 if (ctrl_x_mode == 0 && dec(&first_match_pos) < 0) | 4331 if (ctrl_x_mode == CTRL_X_NORMAL && dec(&first_match_pos) < 0) |
4308 { | 4332 { |
4309 /* Move the cursor to after the last character in the | 4333 /* Move the cursor to after the last character in the |
4310 * buffer, so that word at start of buffer is found | 4334 * buffer, so that word at start of buffer is found |
4311 * correctly. */ | 4335 * correctly. */ |
4312 first_match_pos.lnum = ins_buf->b_ml.ml_line_count; | 4336 first_match_pos.lnum = ins_buf->b_ml.ml_line_count; |
4435 p_ic = ignorecase(compl_pattern); | 4459 p_ic = ignorecase(compl_pattern); |
4436 | 4460 |
4437 /* Find up to TAG_MANY matches. Avoids that an enormous number | 4461 /* Find up to TAG_MANY matches. Avoids that an enormous number |
4438 * of matches is found when compl_pattern is empty */ | 4462 * of matches is found when compl_pattern is empty */ |
4439 if (find_tags(compl_pattern, &num_matches, &matches, | 4463 if (find_tags(compl_pattern, &num_matches, &matches, |
4440 TAG_REGEXP | TAG_NAMES | TAG_NOIC | | 4464 TAG_REGEXP | TAG_NAMES | TAG_NOIC | TAG_INS_COMP |
4441 TAG_INS_COMP | (ctrl_x_mode ? TAG_VERBOSE : 0), | 4465 | (ctrl_x_mode != CTRL_X_NORMAL ? TAG_VERBOSE : 0), |
4442 TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0) | 4466 TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0) |
4443 { | 4467 { |
4444 ins_compl_add_matches(num_matches, matches, p_ic); | 4468 ins_compl_add_matches(num_matches, matches, p_ic); |
4445 } | 4469 } |
4446 p_ic = save_p_ic; | 4470 p_ic = save_p_ic; |
4631 * expansion added something) */ | 4655 * expansion added something) */ |
4632 if (type != 0 && compl_curr_match != compl_old_match) | 4656 if (type != 0 && compl_curr_match != compl_old_match) |
4633 found_new_match = OK; | 4657 found_new_match = OK; |
4634 | 4658 |
4635 /* break the loop for specialized modes (use 'complete' just for the | 4659 /* break the loop for specialized modes (use 'complete' just for the |
4636 * generic ctrl_x_mode == 0) or when we've found a new match */ | 4660 * generic ctrl_x_mode == CTRL_X_NORMAL) or when we've found a new |
4637 if ((ctrl_x_mode != 0 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | 4661 * match */ |
4662 if ((ctrl_x_mode != CTRL_X_NORMAL | |
4663 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | |
4638 || found_new_match != FAIL) | 4664 || found_new_match != FAIL) |
4639 { | 4665 { |
4640 if (got_int) | 4666 if (got_int) |
4641 break; | 4667 break; |
4642 /* Fill the popup menu as soon as possible. */ | 4668 /* Fill the popup menu as soon as possible. */ |
4643 if (type != -1) | 4669 if (type != -1) |
4644 ins_compl_check_keys(0, FALSE); | 4670 ins_compl_check_keys(0, FALSE); |
4645 | 4671 |
4646 if ((ctrl_x_mode != 0 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | 4672 if ((ctrl_x_mode != CTRL_X_NORMAL |
4673 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | |
4647 || compl_interrupted) | 4674 || compl_interrupted) |
4648 break; | 4675 break; |
4649 compl_started = TRUE; | 4676 compl_started = TRUE; |
4650 } | 4677 } |
4651 else | 4678 else |
4657 compl_started = FALSE; | 4684 compl_started = FALSE; |
4658 } | 4685 } |
4659 } | 4686 } |
4660 compl_started = TRUE; | 4687 compl_started = TRUE; |
4661 | 4688 |
4662 if ((ctrl_x_mode == 0 || CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) | 4689 if ((ctrl_x_mode == CTRL_X_NORMAL || CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)) |
4663 && *e_cpt == NUL) /* Got to end of 'complete' */ | 4690 && *e_cpt == NUL) /* Got to end of 'complete' */ |
4664 found_new_match = FAIL; | 4691 found_new_match = FAIL; |
4665 | 4692 |
4666 i = -1; /* total of matches, unknown */ | 4693 i = -1; /* total of matches, unknown */ |
4667 if (found_new_match == FAIL | 4694 if (found_new_match == FAIL || (ctrl_x_mode != CTRL_X_NORMAL |
4668 || (ctrl_x_mode != 0 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode))) | 4695 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode))) |
4669 i = ins_compl_make_cyclic(); | 4696 i = ins_compl_make_cyclic(); |
4670 | 4697 |
4671 if (compl_old_match != NULL) | 4698 if (compl_old_match != NULL) |
4672 { | 4699 { |
4673 /* If several matches were added (FORWARD) or the search failed and has | 4700 /* If several matches were added (FORWARD) or the search failed and has |
5164 { | 5191 { |
5165 /* | 5192 /* |
5166 * it is a continued search | 5193 * it is a continued search |
5167 */ | 5194 */ |
5168 compl_cont_status &= ~CONT_INTRPT; /* remove INTRPT */ | 5195 compl_cont_status &= ~CONT_INTRPT; /* remove INTRPT */ |
5169 if (ctrl_x_mode == 0 || ctrl_x_mode == CTRL_X_PATH_PATTERNS | 5196 if (ctrl_x_mode == CTRL_X_NORMAL |
5170 || ctrl_x_mode == CTRL_X_PATH_DEFINES) | 5197 || ctrl_x_mode == CTRL_X_PATH_PATTERNS |
5198 || ctrl_x_mode == CTRL_X_PATH_DEFINES) | |
5171 { | 5199 { |
5172 if (compl_startpos.lnum != curwin->w_cursor.lnum) | 5200 if (compl_startpos.lnum != curwin->w_cursor.lnum) |
5173 { | 5201 { |
5174 /* line (probably) wrapped, set compl_startpos to the | 5202 /* line (probably) wrapped, set compl_startpos to the |
5175 * first non_blank in the line, if it is not a wordchar | 5203 * first non_blank in the line, if it is not a wordchar |
5217 compl_cont_status &= CONT_LOCAL; | 5245 compl_cont_status &= CONT_LOCAL; |
5218 | 5246 |
5219 if (!(compl_cont_status & CONT_ADDING)) /* normal expansion */ | 5247 if (!(compl_cont_status & CONT_ADDING)) /* normal expansion */ |
5220 { | 5248 { |
5221 compl_cont_mode = ctrl_x_mode; | 5249 compl_cont_mode = ctrl_x_mode; |
5222 if (ctrl_x_mode != 0) /* Remove LOCAL if ctrl_x_mode != 0 */ | 5250 if (ctrl_x_mode != CTRL_X_NORMAL) |
5251 /* Remove LOCAL if ctrl_x_mode != CTRL_X_NORMAL */ | |
5223 compl_cont_status = 0; | 5252 compl_cont_status = 0; |
5224 compl_cont_status |= CONT_N_ADDS; | 5253 compl_cont_status |= CONT_N_ADDS; |
5225 compl_startpos = curwin->w_cursor; | 5254 compl_startpos = curwin->w_cursor; |
5226 startcol = (int)curs_col; | 5255 startcol = (int)curs_col; |
5227 compl_col = 0; | 5256 compl_col = 0; |
5228 } | 5257 } |
5229 | 5258 |
5230 /* Work out completion pattern and original text -- webb */ | 5259 /* Work out completion pattern and original text -- webb */ |
5231 if (ctrl_x_mode == 0 || (ctrl_x_mode & CTRL_X_WANT_IDENT)) | 5260 if (ctrl_x_mode == CTRL_X_NORMAL || (ctrl_x_mode & CTRL_X_WANT_IDENT)) |
5232 { | 5261 { |
5233 if ((compl_cont_status & CONT_SOL) | 5262 if ((compl_cont_status & CONT_SOL) |
5234 || ctrl_x_mode == CTRL_X_PATH_DEFINES) | 5263 || ctrl_x_mode == CTRL_X_PATH_DEFINES) |
5235 { | 5264 { |
5236 if (!(compl_cont_status & CONT_ADDING)) | 5265 if (!(compl_cont_status & CONT_ADDING)) |
5443 * Return value -3 does the same as -2 and leaves CTRL-X mode.*/ | 5472 * Return value -3 does the same as -2 and leaves CTRL-X mode.*/ |
5444 if (col == -2) | 5473 if (col == -2) |
5445 return FAIL; | 5474 return FAIL; |
5446 if (col == -3) | 5475 if (col == -3) |
5447 { | 5476 { |
5448 ctrl_x_mode = 0; | 5477 ctrl_x_mode = CTRL_X_NORMAL; |
5449 edit_submode = NULL; | 5478 edit_submode = NULL; |
5450 if (!shortmess(SHM_COMPLETIONMENU)) | 5479 if (!shortmess(SHM_COMPLETIONMENU)) |
5451 msg_clr_cmdline(); | 5480 msg_clr_cmdline(); |
5452 return FAIL; | 5481 return FAIL; |
5453 } | 5482 } |
5602 * because we couldn't expand anything at first place, but if we used | 5631 * because we couldn't expand anything at first place, but if we used |
5603 * ^P, ^N, ^X^I or ^X^D we might want to add-expand a single-char-word | 5632 * ^P, ^N, ^X^I or ^X^D we might want to add-expand a single-char-word |
5604 * (such as M in M'exico) if not tried already. -- Acevedo */ | 5633 * (such as M in M'exico) if not tried already. -- Acevedo */ |
5605 if ( compl_length > 1 | 5634 if ( compl_length > 1 |
5606 || (compl_cont_status & CONT_ADDING) | 5635 || (compl_cont_status & CONT_ADDING) |
5607 || (ctrl_x_mode != 0 | 5636 || (ctrl_x_mode != CTRL_X_NORMAL |
5608 && ctrl_x_mode != CTRL_X_PATH_PATTERNS | 5637 && ctrl_x_mode != CTRL_X_PATH_PATTERNS |
5609 && ctrl_x_mode != CTRL_X_PATH_DEFINES)) | 5638 && ctrl_x_mode != CTRL_X_PATH_DEFINES)) |
5610 compl_cont_status &= ~CONT_N_ADDS; | 5639 compl_cont_status &= ~CONT_N_ADDS; |
5611 } | 5640 } |
5612 | 5641 |