To: vim-dev@vim.org Subject: Patch 5.6.016 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.016 Problem: When deleting a search string from history from inside a mapping, another entry is deleted too. (Benji Fisher) Solution: Reset last_maptick when deleting the last entry of the search history. Also: Increment maptick when starting a mapping from typed characters to avoid a just added search string being overwritten or removed from history. Files: src/ex_getln.c, src/getchar.c *** ../vim-5.6.15/src/ex_getln.c Thu Mar 23 17:46:04 2000 --- src/ex_getln.c Fri Mar 24 10:08:19 2000 *************** *** 3090,3095 **** --- 3090,3097 ---- return -1; } + static int last_maptick = -1; /* last seen maptick */ + /* * Add the given string to the given history. If the string is already in the * history then it is moved to the front. "histype" may be HIST_CMD, *************** *** 3101,3107 **** char_u *new_entry; int in_map; /* consider maptick when inside a mapping */ { - static int last_maptick = -1; /* last seen maptick */ struct hist_entry *hisptr; if (hislen == 0) /* no history */ --- 3103,3108 ---- *************** *** 3307,3315 **** i = calc_hist_idx(histype, idx); if (i < 0) return FALSE; - idx = hisidx[histype]; vim_free(history[histype][i].hisstr); while (i != idx) { j = (i + 1) % hislen; --- 3308,3322 ---- i = calc_hist_idx(histype, idx); if (i < 0) return FALSE; idx = hisidx[histype]; vim_free(history[histype][i].hisstr); + + /* When deleting the last added search string in a mapping, reset + * last_maptick, so that the last added search string isn't deleted again. + */ + if (histype == HIST_SEARCH && maptick == last_maptick && i == idx) + last_maptick = -1; + while (i != idx) { j = (i + 1) % hislen; *** ../vim-5.6.15/src/getchar.c Mon Sep 13 13:32:42 1999 --- src/getchar.c Fri Mar 24 10:42:26 2000 *************** *** 881,886 **** --- 881,890 ---- } } may_sync_undo(); + + /* Since characters have been typed, consider the following to be in + * another mapping. Search string will be kept in history. */ + ++maptick; } /* *************** *** 1500,1506 **** else { KeyTyped = TRUE; - ++maptick; /* write char to script file(s) */ gotchars(typebuf + typeoff, 1); } --- 1516,1521 ---- *** ../vim-5.6.15/src/version.c Thu Mar 23 17:46:05 2000 --- src/version.c Fri Mar 24 10:47:30 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 16, /**/ -- GOD: That is your purpose Arthur ... the Quest for the Holy Grail ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/