Mercurial > vim
comparison src/edit.c @ 909:073f98f45a44 v7.0.035
updated for version 7.0-035
author | vimboss |
---|---|
date | Fri, 23 Jun 2006 19:36:29 +0000 |
parents | bd7e26d05a3f |
children | 2448f4c8afc6 |
comparison
equal
deleted
inserted
replaced
908:bd7e26d05a3f | 909:073f98f45a44 |
---|---|
4164 * around. */ | 4164 * around. */ |
4165 while (--todo >= 0) | 4165 while (--todo >= 0) |
4166 { | 4166 { |
4167 if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL) | 4167 if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL) |
4168 { | 4168 { |
4169 if (compl_pending != 0) | |
4170 --compl_pending; | |
4171 compl_shown_match = compl_shown_match->cp_next; | 4169 compl_shown_match = compl_shown_match->cp_next; |
4172 found_end = (compl_first_match != NULL | 4170 found_end = (compl_first_match != NULL |
4173 && (compl_shown_match->cp_next == compl_first_match | 4171 && (compl_shown_match->cp_next == compl_first_match |
4174 || compl_shown_match == compl_first_match)); | 4172 || compl_shown_match == compl_first_match)); |
4175 } | 4173 } |
4176 else if (compl_shows_dir == BACKWARD | 4174 else if (compl_shows_dir == BACKWARD |
4177 && compl_shown_match->cp_prev != NULL) | 4175 && compl_shown_match->cp_prev != NULL) |
4178 { | 4176 { |
4179 if (compl_pending != 0) | |
4180 ++compl_pending; | |
4181 found_end = (compl_shown_match == compl_first_match); | 4177 found_end = (compl_shown_match == compl_first_match); |
4182 compl_shown_match = compl_shown_match->cp_prev; | 4178 compl_shown_match = compl_shown_match->cp_prev; |
4183 found_end |= (compl_shown_match == compl_first_match); | 4179 found_end |= (compl_shown_match == compl_first_match); |
4184 } | 4180 } |
4185 else | 4181 else |
4186 { | 4182 { |
4183 if (!allow_get_expansion) | |
4184 { | |
4185 if (advance) | |
4186 { | |
4187 if (compl_shows_dir == BACKWARD) | |
4188 compl_pending -= todo + 1; | |
4189 else | |
4190 compl_pending += todo + 1; | |
4191 } | |
4192 return -1; | |
4193 } | |
4194 | |
4187 if (advance) | 4195 if (advance) |
4188 { | 4196 { |
4189 if (compl_shows_dir == BACKWARD) | 4197 if (compl_shows_dir == BACKWARD) |
4190 --compl_pending; | 4198 --compl_pending; |
4191 else | 4199 else |
4192 ++compl_pending; | 4200 ++compl_pending; |
4193 } | 4201 } |
4194 if (!allow_get_expansion) | |
4195 return -1; | |
4196 | 4202 |
4197 /* Find matches. */ | 4203 /* Find matches. */ |
4198 num_matches = ins_compl_get_exp(&compl_startpos); | 4204 num_matches = ins_compl_get_exp(&compl_startpos); |
4199 if (compl_pending != 0 && compl_direction == compl_shows_dir | 4205 |
4206 /* handle any pending completions */ | |
4207 while (compl_pending != 0 && compl_direction == compl_shows_dir | |
4200 && advance) | 4208 && advance) |
4201 compl_shown_match = compl_curr_match; | 4209 { |
4210 if (compl_pending > 0 && compl_shown_match->cp_next != NULL) | |
4211 { | |
4212 compl_shown_match = compl_shown_match->cp_next; | |
4213 --compl_pending; | |
4214 } | |
4215 if (compl_pending < 0 && compl_shown_match->cp_prev != NULL) | |
4216 { | |
4217 compl_shown_match = compl_shown_match->cp_prev; | |
4218 ++compl_pending; | |
4219 } | |
4220 else | |
4221 break; | |
4222 } | |
4202 found_end = FALSE; | 4223 found_end = FALSE; |
4203 } | 4224 } |
4204 if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0 | 4225 if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0 |
4205 && compl_leader != NULL | 4226 && compl_leader != NULL |
4206 && !ins_compl_equal(compl_shown_match, | 4227 && !ins_compl_equal(compl_shown_match, |
4305 /* Only do this at regular intervals */ | 4326 /* Only do this at regular intervals */ |
4306 if (++count < frequency) | 4327 if (++count < frequency) |
4307 return; | 4328 return; |
4308 count = 0; | 4329 count = 0; |
4309 | 4330 |
4310 ++no_mapping; | 4331 /* Check for a typed key. Do use mappings, otherwise vim_is_ctrl_x_key() |
4332 * can't do its work correctly. */ | |
4311 c = vpeekc_any(); | 4333 c = vpeekc_any(); |
4312 --no_mapping; | |
4313 if (c != NUL) | 4334 if (c != NUL) |
4314 { | 4335 { |
4315 if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R) | 4336 if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R) |
4316 { | 4337 { |
4317 c = safe_vgetc(); /* Eat the character */ | 4338 c = safe_vgetc(); /* Eat the character */ |
4318 compl_shows_dir = ins_compl_key2dir(c); | 4339 compl_shows_dir = ins_compl_key2dir(c); |
4319 (void)ins_compl_next(FALSE, ins_compl_key2count(c), | 4340 (void)ins_compl_next(FALSE, ins_compl_key2count(c), |
4320 c != K_UP && c != K_DOWN); | 4341 c != K_UP && c != K_DOWN); |
4321 } | 4342 } |
4322 else if (c != Ctrl_R) | 4343 else |
4323 compl_interrupted = TRUE; | 4344 { |
4345 /* Need to get the character to have KeyTyped set. We'll put it | |
4346 * back with vungetc() below. */ | |
4347 c = safe_vgetc(); | |
4348 | |
4349 /* Don't interrupt completion when the character wasn't typed, | |
4350 * e.g., when doing @q to replay keys. */ | |
4351 if (c != Ctrl_R && KeyTyped) | |
4352 compl_interrupted = TRUE; | |
4353 | |
4354 vungetc(c); | |
4355 } | |
4324 } | 4356 } |
4325 if (compl_pending != 0 && !got_int) | 4357 if (compl_pending != 0 && !got_int) |
4326 (void)ins_compl_next(FALSE, compl_pending > 0 | 4358 { |
4327 ? compl_pending : -compl_pending, TRUE); | 4359 int todo = compl_pending > 0 ? compl_pending : -compl_pending; |
4360 | |
4361 compl_pending = 0; | |
4362 (void)ins_compl_next(FALSE, todo, TRUE); | |
4363 } | |
4328 } | 4364 } |
4329 | 4365 |
4330 /* | 4366 /* |
4331 * Decide the direction of Insert mode complete from the key typed. | 4367 * Decide the direction of Insert mode complete from the key typed. |
4332 * Returns BACKWARD or FORWARD. | 4368 * Returns BACKWARD or FORWARD. |