comparison src/edit.c @ 887:9dc77520c6d3 v7.0.013

updated for version 7.0-013
author vimboss
date Sat, 13 May 2006 13:24:33 +0000
parents 4bac29d27e2f
children 2e1e9b708941
comparison
equal deleted inserted replaced
886:ddfb6f3f3b2b 887:9dc77520c6d3
749 { 749 {
750 ins_compl_addleader(c); 750 ins_compl_addleader(c);
751 continue; 751 continue;
752 } 752 }
753 753
754 /* Pressing CTRL-Y selects the current match. Shen 754 /* Pressing CTRL-Y selects the current match. When
755 * compl_enter_selects is set the Enter key does the same. */ 755 * compl_enter_selects is set the Enter key does the same. */
756 if (c == Ctrl_Y || (compl_enter_selects 756 if (c == Ctrl_Y || (compl_enter_selects
757 && (c == CAR || c == K_KENTER || c == NL))) 757 && (c == CAR || c == K_KENTER || c == NL)))
758 { 758 {
759 ins_compl_delete(); 759 ins_compl_delete();
3044 { 3044 {
3045 ins_compl_del_pum(); 3045 ins_compl_del_pum();
3046 ins_compl_delete(); 3046 ins_compl_delete();
3047 ins_bytes(compl_leader + curwin->w_cursor.col - compl_col); 3047 ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
3048 compl_used_match = FALSE; 3048 compl_used_match = FALSE;
3049 compl_enter_selects = FALSE;
3050 3049
3051 if (compl_started) 3050 if (compl_started)
3052 ins_compl_set_original_text(compl_leader); 3051 ins_compl_set_original_text(compl_leader);
3053 else 3052 else
3054 { 3053 {
3074 if (ins_complete(Ctrl_N) == FAIL) 3073 if (ins_complete(Ctrl_N) == FAIL)
3075 compl_cont_status = 0; 3074 compl_cont_status = 0;
3076 compl_restarting = FALSE; 3075 compl_restarting = FALSE;
3077 } 3076 }
3078 3077
3078 #if 0 /* disabled, made CTRL-L, BS and typing char jump to original text. */
3079 if (!compl_used_match) 3079 if (!compl_used_match)
3080 { 3080 {
3081 /* Go to the original text, since none of the matches is inserted. */ 3081 /* Go to the original text, since none of the matches is inserted. */
3082 if (compl_first_match->cp_prev != NULL 3082 if (compl_first_match->cp_prev != NULL
3083 && (compl_first_match->cp_prev->cp_flags & ORIGINAL_TEXT)) 3083 && (compl_first_match->cp_prev->cp_flags & ORIGINAL_TEXT))
3085 else 3085 else
3086 compl_shown_match = compl_first_match; 3086 compl_shown_match = compl_first_match;
3087 compl_curr_match = compl_shown_match; 3087 compl_curr_match = compl_shown_match;
3088 compl_shows_dir = compl_direction; 3088 compl_shows_dir = compl_direction;
3089 } 3089 }
3090 #endif
3091 compl_enter_selects = !compl_used_match;
3090 3092
3091 /* Show the popup menu with a different set of matches. */ 3093 /* Show the popup menu with a different set of matches. */
3092 ins_compl_show_pum(); 3094 ins_compl_show_pum();
3093 } 3095 }
3094 3096
3173 ins_compl_addfrommatch() 3175 ins_compl_addfrommatch()
3174 { 3176 {
3175 char_u *p; 3177 char_u *p;
3176 int len = curwin->w_cursor.col - compl_col; 3178 int len = curwin->w_cursor.col - compl_col;
3177 int c; 3179 int c;
3180 compl_T *cp;
3178 3181
3179 p = compl_shown_match->cp_str; 3182 p = compl_shown_match->cp_str;
3180 if ((int)STRLEN(p) <= len) /* the match is too short */ 3183 if ((int)STRLEN(p) <= len) /* the match is too short */
3181 return; 3184 {
3185 /* When still at the original match use the first entry that matches
3186 * the leader. */
3187 if (compl_shown_match->cp_flags & ORIGINAL_TEXT)
3188 {
3189 p = NULL;
3190 for (cp = compl_shown_match->cp_next; cp != NULL
3191 && cp != compl_first_match; cp = cp->cp_next)
3192 {
3193 if (ins_compl_equal(cp, compl_leader,
3194 (int)STRLEN(compl_leader)))
3195 {
3196 p = cp->cp_str;
3197 break;
3198 }
3199 }
3200 if (p == NULL || (int)STRLEN(p) <= len)
3201 return;
3202 }
3203 else
3204 return;
3205 }
3182 p += len; 3206 p += len;
3183 #ifdef FEAT_MBYTE 3207 #ifdef FEAT_MBYTE
3184 c = mb_ptr2char(p); 3208 c = mb_ptr2char(p);
3185 #else 3209 #else
3186 c = *p; 3210 c = *p;
4098 while (!ins_compl_equal(compl_shown_match, 4122 while (!ins_compl_equal(compl_shown_match,
4099 compl_leader, (int)STRLEN(compl_leader)) 4123 compl_leader, (int)STRLEN(compl_leader))
4100 && compl_shown_match->cp_next != NULL 4124 && compl_shown_match->cp_next != NULL
4101 && compl_shown_match->cp_next != compl_first_match) 4125 && compl_shown_match->cp_next != compl_first_match)
4102 compl_shown_match = compl_shown_match->cp_next; 4126 compl_shown_match = compl_shown_match->cp_next;
4127
4128 /* If we didn't find it searching forward, and compl_shows_dir is
4129 * backward, find the last match. */
4130 if (compl_shows_dir == BACKWARD
4131 && !ins_compl_equal(compl_shown_match,
4132 compl_leader, (int)STRLEN(compl_leader))
4133 && (compl_shown_match->cp_next == NULL
4134 || compl_shown_match->cp_next == compl_first_match))
4135 {
4136 while (!ins_compl_equal(compl_shown_match,
4137 compl_leader, (int)STRLEN(compl_leader))
4138 && compl_shown_match->cp_prev != NULL
4139 && compl_shown_match->cp_prev != compl_first_match)
4140 compl_shown_match = compl_shown_match->cp_prev;
4141 }
4103 } 4142 }
4104 4143
4105 if (allow_get_expansion && insert_match 4144 if (allow_get_expansion && insert_match
4106 && (!(compl_get_longest || compl_restarting) || compl_used_match)) 4145 && (!(compl_get_longest || compl_restarting) || compl_used_match))
4107 /* Delete old text to be replaced */ 4146 /* Delete old text to be replaced */