To: vim_dev@googlegroups.com Subject: Patch 8.2.4378 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4378 Problem: Incsearch highlight broken when calling searchcount() in 'tabLine' function. (Mirko Palmer) Solution: Save and restore the incsearch state. (Christian Brabandt, closes #9763, closes #9633) Files: src/search.c, src/testdir/test_search_stat.vim, src/testdir/dumps/Test_searchstat_inc_1.dump, src/testdir/dumps/Test_searchstat_inc_2.dump, src/testdir/dumps/Test_searchstat_inc_3.dump *** ../vim-8.2.4377/src/search.c 2022-01-04 17:01:40.598663106 +0000 --- src/search.c 2022-02-14 12:42:31.619703273 +0000 *************** *** 325,330 **** --- 325,332 ---- static int did_save_last_search_spat = 0; static int saved_last_idx = 0; static int saved_no_hlsearch = 0; + static int saved_search_match_endcol; + static int saved_search_match_lines; /* * Save and restore the search pattern for incremental highlight search *************** *** 370,375 **** --- 372,396 ---- set_no_hlsearch(saved_no_hlsearch); } + /* + * Save and restore the incsearch highlighting variables. + * This is required so that calling searchcount() at does not invalidate the + * incsearch highlighting. + */ + static void + save_incsearch_state(void) + { + saved_search_match_endcol = search_match_endcol; + saved_search_match_lines = search_match_lines; + } + + static void + restore_incsearch_state(void) + { + search_match_endcol = saved_search_match_endcol; + search_match_lines = saved_search_match_lines; + } + char_u * last_search_pattern(void) { *************** *** 4182,4187 **** --- 4203,4211 ---- } save_last_search_pattern(); + #ifdef FEAT_SEARCH_EXTRA + save_incsearch_state(); + #endif if (pattern != NULL) { if (*pattern == NUL) *************** *** 4202,4207 **** --- 4226,4234 ---- the_end: restore_last_search_pattern(); + #ifdef FEAT_SEARCH_EXTRA + restore_incsearch_state(); + #endif } /* *** ../vim-8.2.4377/src/testdir/test_search_stat.vim 2022-02-10 19:51:42.549569899 +0000 --- src/testdir/test_search_stat.vim 2022-02-14 12:43:31.759551853 +0000 *************** *** 371,376 **** --- 371,418 ---- call delete('Xsearchstatgd') endfunc + func Test_search_stat_and_incsearch() + CheckScreendump + + let lines =<< trim END + call setline(1, ['abc--c', '--------abc', '--abc']) + set hlsearch + set incsearch + set bg=dark + set showtabline=2 + + function MyTabLine() + try + let a=searchcount(#{recompute: 1, maxcount: -1}) + return a.current .. '/' .. a.total + catch + return '' + endtry + endfunction + + set tabline=%!MyTabLine() + END + call writefile(lines, 'Xsearchstat_inc') + + let buf = RunVimInTerminal('-S Xsearchstat_inc', #{rows: 10}) + call term_sendkeys(buf, "/abc") + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_searchstat_inc_1', {}) + + call term_sendkeys(buf, "\") + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_searchstat_inc_2', {}) + + call term_sendkeys(buf, "\") + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_searchstat_inc_3', {}) + + call term_sendkeys(buf, "\:qa\") + call TermWait(buf) + + call StopVimInTerminal(buf) + call delete('Xsearchstat_inc') + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4377/src/testdir/dumps/Test_searchstat_inc_1.dump 2022-02-14 12:43:56.531491051 +0000 --- src/testdir/dumps/Test_searchstat_inc_1.dump 2022-02-14 12:35:15.072656758 +0000 *************** *** 0 **** --- 1,10 ---- + | +1&#ffffff0@74 + |a+0#0000001#ffff4012|b|c|-+0#0000000#ffffff0@1|c| @68 + |-@7|a+1&&|b|c| +0&&@63 + |-@1|a+0#0000001#ffff4012|b|c| +0#0000000#ffffff0@69 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |/+0#0000000&|a|b|c> @70 *** ../vim-8.2.4377/src/testdir/dumps/Test_searchstat_inc_2.dump 2022-02-14 12:43:56.535491040 +0000 --- src/testdir/dumps/Test_searchstat_inc_2.dump 2022-02-14 12:35:15.072656758 +0000 *************** *** 0 **** --- 1,10 ---- + |3+1&#ffffff0|/|3| @71 + |a+0#0000001#ffff4012|b|c|-+0#0000000#ffffff0@1|c| @68 + |-@7|a+0#0000001#ffff4012|b|c| +0#0000000#ffffff0@63 + |-@1|a+1&&|b|c| +0&&@69 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |/+0#0000000&|a|b|c> @70 *** ../vim-8.2.4377/src/testdir/dumps/Test_searchstat_inc_3.dump 2022-02-14 12:43:56.539491032 +0000 --- src/testdir/dumps/Test_searchstat_inc_3.dump 2022-02-14 12:35:15.072656758 +0000 *************** *** 0 **** --- 1,10 ---- + |1+1&#ffffff0|/|3| @71 + |a|b|c|-+0&&@1|c| @68 + |-@7|a+0#0000001#ffff4012|b|c| +0#0000000#ffffff0@63 + |-@1|a+0#0000001#ffff4012|b|c| +0#0000000#ffffff0@69 + |~+0#4040ff13&| @73 + |~| @73 + |~| @73 + |~| @73 + |~| @73 + |/+0#0000000&|a|b|c> @70 *** ../vim-8.2.4377/src/version.c 2022-02-14 11:36:53.795908024 +0000 --- src/version.c 2022-02-14 12:38:37.816339239 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4378, /**/ -- The 50-50-90 rule: Anytime you have a 50-50 chance of getting something right, there's a 90% probability you'll get it wrong. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///