diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-07 07:57:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-07 07:57:29 +0800 |
commit | 9e34aa76c132b5637ed2f2dafa4487f4c850bf35 (patch) | |
tree | 263b1f59a368577352fd809f4bfb021acec4b176 /src | |
parent | e218965338ad8020935a10e678d2a7c6a059ee43 (diff) | |
download | rneovim-9e34aa76c132b5637ed2f2dafa4487f4c850bf35.tar.gz rneovim-9e34aa76c132b5637ed2f2dafa4487f4c850bf35.tar.bz2 rneovim-9e34aa76c132b5637ed2f2dafa4487f4c850bf35.zip |
vim-patch:9.0.1518: search stats not always visible when searching backwards (#23517)
Problem: Search stats not always visible when searching backwards.
Solution: Do not display the top/bot message on top of the search stats.
(Christian Brabandt, closes vim/vim#12322, closes vim/vim#12222)
https://github.com/vim/vim/commit/34a6a3617b5b6ce11372439f14762caddc4b0cea
Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/option_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/search.c | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 944cc583b3..dc652054e8 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -259,7 +259,7 @@ enum { SHM_COMPLETIONSCAN = 'C', ///< Completion scanning messages. SHM_RECORDING = 'q', ///< Short recording message. SHM_FILEINFO = 'F', ///< No file info messages. - SHM_SEARCHCOUNT = 'S', ///< Search stats: '[1/10]' + SHM_SEARCHCOUNT = 'S', ///< No search stats: '[1/10]' SHM_LEN = 30, ///< Max length of all flags together plus a NUL character. }; /// Represented by 'a' flag. diff --git a/src/nvim/search.c b/src/nvim/search.c index 8f1e9148d4..d1a31a357f 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -913,19 +913,22 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, || found || loop) { break; } - // + // If 'wrapscan' is set we continue at the other end of the file. - // If 'shortmess' does not contain 's', we give a message. + // If 'shortmess' does not contain 's', we give a message, but + // only, if we won't show the search stat later anyhow, + // (so SEARCH_COUNT must be absent). // This message is also remembered in keep_msg for when the screen // is redrawn. The keep_msg is cleared whenever another message is // written. - // if (dir == BACKWARD) { // start second loop at the other end lnum = buf->b_ml.ml_line_count; } else { lnum = 1; } - if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG)) { + if (!shortmess(SHM_SEARCH) + && shortmess(SHM_SEARCHCOUNT) + && (options & SEARCH_MSG)) { give_warning(_(dir == BACKWARD ? top_bot_msg : bot_top_msg), true); } if (extra_arg != NULL) { @@ -2702,8 +2705,10 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst lbuf = curbuf; } + // when searching backwards and having jumped to the first occurrence, + // cur must remain greater than 1 if (equalpos(lastpos, *cursor_pos) && !wraparound - && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0)) { + && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 1)) { cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1; } else { proftime_T start; |