diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GvimExt/GvimExt.reg | 4 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/edit.c | 140 | ||||
-rw-r--r-- | src/version.h | 18 |
4 files changed, 108 insertions, 56 deletions
diff --git a/src/GvimExt/GvimExt.reg b/src/GvimExt/GvimExt.reg index bb906e26c..2b80956d8 100644 --- a/src/GvimExt/GvimExt.reg +++ b/src/GvimExt/GvimExt.reg @@ -15,6 +15,6 @@ REGEDIT4 [HKEY_LOCAL_MACHINE\Software\Vim\Gvim] "path"="gvim.exe" -[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0g] - "DisplayName"="Vim 7.0g: Edit with Vim popup menu entry" +[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0] + "DisplayName"="Vim 7.0: Edit with Vim popup menu entry" "UninstallString"="uninstal.exe" diff --git a/src/Makefile b/src/Makefile index 32f3a97c6..b9627ab31 100644 --- a/src/Makefile +++ b/src/Makefile @@ -880,7 +880,7 @@ MAN1DIR = /man1 ### Vim version (adjusted by a script) VIMMAJOR = 7 -VIMMINOR = 0g +VIMMINOR = 0 ### Location of Vim files (should not need to be changed, and {{{1 ### some things might not work when they are changed!) diff --git a/src/edit.c b/src/edit.c index e298a8c38..9b3a528b0 100644 --- a/src/edit.c +++ b/src/edit.c @@ -105,6 +105,11 @@ static int compl_used_match; /* Selected one of the matches. When FALSE the match was edited or using the longest common string. */ +static int compl_was_interrupted = FALSE; /* didn't finish finding + completions. */ + +static int compl_restarting = FALSE; /* don't insert match */ + /* When the first completion is done "compl_started" is set. When it's * FALSE the word to be completed must be located. */ static int compl_started = FALSE; @@ -139,7 +144,9 @@ static char_u *find_line_end __ARGS((char_u *ptr)); static void ins_compl_free __ARGS((void)); static void ins_compl_clear __ARGS((void)); static int ins_compl_bs __ARGS((void)); +static void ins_compl_new_leader __ARGS((void)); static void ins_compl_addleader __ARGS((int c)); +static void ins_compl_restart __ARGS((void)); static void ins_compl_set_original_text __ARGS((char_u *str)); static void ins_compl_addfrommatch __ARGS((void)); static int ins_compl_prep __ARGS((int c)); @@ -3008,43 +3015,69 @@ ins_compl_bs() if ((int)(p - line) - (int)compl_col <= 0) return K_BS; - if (curwin->w_cursor.col <= compl_col + compl_length) - { - /* Deleted more than what was used to find matches, need to look for - * matches all over again. */ - ins_compl_free(); - compl_started = FALSE; - compl_matches = 0; - compl_cont_status = 0; - compl_cont_mode = 0; - } + /* For redo we need to repeat this backspace. */ + AppendCharToRedobuff(K_BS); + + /* Deleted more than what was used to find matches or didn't finish + * finding all matches: need to look for matches all over again. */ + if (curwin->w_cursor.col <= compl_col + compl_length + || compl_was_interrupted) + ins_compl_restart(); vim_free(compl_leader); compl_leader = vim_strnsave(line + compl_col, (int)(p - line) - compl_col); if (compl_leader != NULL) { - ins_compl_del_pum(); - ins_compl_delete(); - ins_bytes(compl_leader + curwin->w_cursor.col - compl_col); + ins_compl_new_leader(); + return NUL; + } + return K_BS; +} - if (compl_started) - ins_compl_set_original_text(compl_leader); - else - { +/* + * Called after changing "compl_leader". + * Show the popup menu with a different set of matches. + * May also search for matches again if the previous search was interrupted. + */ + static void +ins_compl_new_leader() +{ + ins_compl_del_pum(); + ins_compl_delete(); + ins_bytes(compl_leader + curwin->w_cursor.col - compl_col); + compl_used_match = FALSE; + compl_enter_selects = FALSE; + + if (compl_started) + ins_compl_set_original_text(compl_leader); + else + { #ifdef FEAT_SPELL - spell_bad_len = 0; /* need to redetect bad word */ + spell_bad_len = 0; /* need to redetect bad word */ #endif - /* Matches were cleared, need to search for them now. */ - if (ins_complete(Ctrl_N) == FAIL) - compl_cont_status = 0; - else - { - /* Remove the completed word again. */ - ins_compl_delete(); - ins_bytes(compl_leader + curwin->w_cursor.col - compl_col); - } + /* + * Matches were cleared, need to search for them now. First display + * the changed text before the cursor. Set "compl_restarting" to + * avoid that the first match is inserted. + */ + update_screen(0); +#ifdef FEAT_GUI + if (gui.in_use) + { + /* Show the cursor after the match, not after the redrawn text. */ + setcursor(); + out_flush(); + gui_update_cursor(FALSE, FALSE); } +#endif + compl_restarting = TRUE; + if (ins_complete(Ctrl_N) == FAIL) + compl_cont_status = 0; + compl_restarting = FALSE; + } + if (!compl_used_match) + { /* Go to the original text, since none of the matches is inserted. */ if (compl_first_match->cp_prev != NULL && (compl_first_match->cp_prev->cp_flags & ORIGINAL_TEXT)) @@ -3053,15 +3086,10 @@ ins_compl_bs() compl_shown_match = compl_first_match; compl_curr_match = compl_shown_match; compl_shows_dir = compl_direction; - - /* Show the popup menu with a different set of matches. */ - ins_compl_show_pum(); - compl_used_match = FALSE; - compl_enter_selects = FALSE; - - return NUL; } - return K_BS; + + /* Show the popup menu with a different set of matches. */ + ins_compl_show_pum(); } /* @@ -3087,18 +3115,33 @@ ins_compl_addleader(c) #endif ins_char(c); + /* For redo we need to count this character so that the number of + * backspaces is correct. */ + AppendCharToRedobuff(c); + + /* If we didn't complete finding matches we must search again. */ + if (compl_was_interrupted) + ins_compl_restart(); + vim_free(compl_leader); compl_leader = vim_strnsave(ml_get_curline() + compl_col, curwin->w_cursor.col - compl_col); if (compl_leader != NULL) - { - /* Show the popup menu with a different set of matches. */ - ins_compl_del_pum(); - ins_compl_show_pum(); - compl_used_match = FALSE; - compl_enter_selects = FALSE; - ins_compl_set_original_text(compl_leader); - } + ins_compl_new_leader(); +} + +/* + * Setup for finding completions again without leaving CTRL-X mode. Used when + * BS or a key was typed while still searching for matches. + */ + static void +ins_compl_restart() +{ + ins_compl_free(); + compl_started = FALSE; + compl_matches = 0; + compl_cont_status = 0; + compl_cont_mode = 0; } /* @@ -4060,7 +4103,7 @@ ins_compl_next(allow_get_expansion, count, insert_match) } if (allow_get_expansion && insert_match - && (!compl_get_longest || compl_used_match)) + && (!(compl_get_longest || compl_restarting) || compl_used_match)) /* Delete old text to be replaced */ ins_compl_delete(); @@ -4068,6 +4111,13 @@ ins_compl_next(allow_get_expansion, count, insert_match) * don't let CTRL-N or CTRL-P move to the first match. */ advance = count != 1 || !allow_get_expansion || !compl_get_longest; + /* When restarting the search don't insert the first match either. */ + if (compl_restarting) + { + advance = FALSE; + compl_restarting = FALSE; + } + /* Repeat this for when <PageUp> or <PageDown> is typed. But don't wrap * around. */ while (--todo >= 0) @@ -4102,6 +4152,7 @@ ins_compl_next(allow_get_expansion, count, insert_match) if (!allow_get_expansion) return -1; + /* Find matches. */ num_matches = ins_compl_get_exp(&compl_startpos); if (compl_pending != 0 && compl_direction == compl_shows_dir && advance) @@ -4850,6 +4901,7 @@ ins_complete(c) setcursor(); RedrawingDisabled = n; } + compl_was_interrupted = compl_interrupted; compl_interrupted = FALSE; return OK; diff --git a/src/version.h b/src/version.h index 88c9d2ee1..33a435f12 100644 --- a/src/version.h +++ b/src/version.h @@ -19,13 +19,13 @@ #define VIM_VERSION_MINOR_STR "0" #define VIM_VERSION_100 (VIM_VERSION_MAJOR * 100 + VIM_VERSION_MINOR) -#define VIM_VERSION_BUILD 261 -#define VIM_VERSION_BUILD_BCD 0x105 -#define VIM_VERSION_BUILD_STR "261" +#define VIM_VERSION_BUILD 262 +#define VIM_VERSION_BUILD_BCD 0x106 +#define VIM_VERSION_BUILD_STR "262" #define VIM_VERSION_PATCHLEVEL 0 #define VIM_VERSION_PATCHLEVEL_STR "0" /* Used by MacOS port should be one of: development, alpha, beta, final */ -#define VIM_VERSION_RELEASE beta +#define VIM_VERSION_RELEASE final /* * VIM_VERSION_NODOT is used for the runtime directory name. @@ -33,8 +33,8 @@ * VIM_VERSION_MEDIUM is used for the startup-screen. * VIM_VERSION_LONG is used for the ":version" command and "Vim -h". */ -#define VIM_VERSION_NODOT "vim70g" -#define VIM_VERSION_SHORT "7.0g" -#define VIM_VERSION_MEDIUM "7.0g05 BETA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0g05 BETA (2006 May 6)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0g05 BETA (2006 May 6, compiled " +#define VIM_VERSION_NODOT "vim70" +#define VIM_VERSION_SHORT "7.0" +#define VIM_VERSION_MEDIUM "7.0" +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0 (2006 May 7)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0 (2006 May 7, compiled " |