From 973ecd8e90dda246f5f092c6e2e277d2ee488cfb Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Tue, 20 Apr 2021 22:44:13 +0600 Subject: vim-patch:8.2.0887: searchcount().exact_match is 1 right after a match Problem: Searchcount().exact_match is 1 right after a match. Solution: Use LT_POS() instead of LTOREQ_POS(). (closes vim/vim#6189) https://github.com/vim/vim/commit/57f75a5a364ad4d8334fdf6b6b41420b48e08390 --- src/nvim/search.c | 2 +- src/nvim/testdir/test_search_stat.vim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/search.c b/src/nvim/search.c index ba7c5efa83..89ee5b6bb7 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -4489,7 +4489,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, cnt++; if (ltoreq(lastpos, p)) { cur = cnt; - if (ltoreq(p, endpos)) { + if (lt(p, endpos)) { exact_match = true; } } diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim index 3f94877d37..96d4cea002 100644 --- a/src/nvim/testdir/test_search_stat.vim +++ b/src/nvim/testdir/test_search_stat.vim @@ -26,6 +26,14 @@ func Test_search_stat() call assert_equal( \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99}, \ searchcount(#{pattern: 'fooooobar', pos: [3, 1, 0]})) + " on last char of match + call assert_equal( + \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99}, + \ searchcount(#{pattern: 'fooooobar', pos: [3, 9, 0]})) + " on char after match + call assert_equal( + \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, + \ searchcount(#{pattern: 'fooooobar', pos: [3, 10, 0]})) call assert_equal( \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0]})) -- cgit