From aa959f7b858451a9cd0633b703a236f09d2fa44e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 10 Jan 2026 08:03:10 +0800 Subject: [PATCH] vim-patch:9.1.2069: Search wrap indicator not shown w/out 'shm-S' (#37332) Problem: when shortmess doesn't have 'S', backward search wrap doesn't show the "W" before count. forward search works fine but backward fails because the position check logic is backwards - it checks if cursor < pos instead of using the existing wrapped flag. Solution: Use sia->sa_wrapped flag that searchit() already sets correctly (glepnir). fixes: vim/vim#5280 closes: vim/vim#19138 https://github.com/vim/vim/commit/ccb7b433652eae18550ab0dfb35722cc6bf6234c Co-authored-by: glepnir --- src/nvim/search.c | 4 +--- test/functional/legacy/search_stat_spec.lua | 19 +++++++++++++------ test/old/testdir/test_search_stat.vim | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/nvim/search.c b/src/nvim/search.c index 3f70e64e51..68569b6b92 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1356,9 +1356,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, size_t patlen *dircp = (char)search_delim; // restore second '/' or '?' for normal_cmd() } - if (!shortmess(SHM_SEARCH) - && ((dirc == '/' && lt(pos, curwin->w_cursor)) - || (dirc == '?' && lt(curwin->w_cursor, pos)))) { + if (!shortmess(SHM_SEARCH) && sia && sia->sa_wrapped) { show_top_bot_msg = true; } diff --git a/test/functional/legacy/search_stat_spec.lua b/test/functional/legacy/search_stat_spec.lua index 3a112abef6..05def8a7d9 100644 --- a/test/functional/legacy/search_stat_spec.lua +++ b/test/functional/legacy/search_stat_spec.lua @@ -67,10 +67,17 @@ describe('search stat', function() {1:~ }|*5 /foo [1/2] | ]]) + feed('n') + screen:expect([[ + if | + {13:^+-- 2 lines: foo·············}| + endif | + | + {1:~ }|*5 + /foo W [1/2] | + ]]) + feed('n') -- Note: there is an intermediate state where the search stat disappears. - feed('n') - screen:expect_unchanged(true) - feed('n') screen:expect_unchanged(true) end) @@ -163,7 +170,7 @@ describe('search stat', function() {10:^test} | | {1:~ }|*7 - /\ [1/1] | + /\ W [1/1] | ]]) feed('N') @@ -171,7 +178,7 @@ describe('search stat', function() {10:^test} | | {1:~ }|*7 - ?\ [1/1] | + ?\ W [1/1] | ]]) command('set shm+=S') @@ -205,7 +212,7 @@ describe('search stat', function() Mainmainmainmmmain{10:^mAin} | | {1:~ }|*7 - /mAin [1/1] | + /mAin W [1/1] | ]]) end) end) diff --git a/test/old/testdir/test_search_stat.vim b/test/old/testdir/test_search_stat.vim index fddb389c6e..77113fd239 100644 --- a/test/old/testdir/test_search_stat.vim +++ b/test/old/testdir/test_search_stat.vim @@ -332,13 +332,13 @@ func Test_search_stat_foldopen() call writefile(lines, 'Xsearchstat1', 'D') let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10}) - call VerifyScreenDump(buf, 'Test_searchstat_3', {}) + call VerifyScreenDump(buf, 'Test_searchfoldopen_1', {}) call term_sendkeys(buf, "n") - call VerifyScreenDump(buf, 'Test_searchstat_3', {}) + call VerifyScreenDump(buf, 'Test_searchfoldopen_2', {}) call term_sendkeys(buf, "n") - call VerifyScreenDump(buf, 'Test_searchstat_3', {}) + call VerifyScreenDump(buf, 'Test_searchfoldopen_2', {}) call StopVimInTerminal(buf) endfunc