diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-11-02 23:22:47 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-11-02 23:22:47 +0100 |
commit | 82cf7f6df751505da285815a791463a049587849 (patch) | |
tree | bfe62548a532d52220a7277745f5bf0c4ac41116 | |
parent | 32aa10203bd0b4b270def03311a4599f9ffdecc4 (diff) | |
download | vim-git-82cf7f6df751505da285815a791463a049587849.tar.gz |
patch 8.1.2244: 'wrapscan' is not used for "gn"v8.1.2244
Problem: 'wrapscan' is not used for "gn".
Solution: Only reset 'wrapscan' for the first search round. (closes #5164)
-rw-r--r-- | src/search.c | 14 | ||||
-rw-r--r-- | src/testdir/test_gn.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/search.c b/src/search.c index 18f7905e5..00f0a08ff 100644 --- a/src/search.c +++ b/src/search.c @@ -4765,9 +4765,6 @@ current_search( pos_T save_VIsual = VIsual; int zero_width; - /* wrapping should not occur */ - p_ws = FALSE; - /* Correct cursor when 'selection' is exclusive */ if (VIsual_active && *p_sel == 'e' && LT_POS(VIsual, curwin->w_cursor)) dec_cursor(); @@ -4786,10 +4783,7 @@ current_search( zero_width = is_zero_width(spats[last_idx].pat, TRUE, &curwin->w_cursor, FORWARD); if (zero_width == -1) - { - p_ws = old_p_ws; return FAIL; /* pattern not found */ - } /* * The trick is to first search backwards and then search forward again, @@ -4808,11 +4802,17 @@ current_search( flags = SEARCH_END; end_pos = pos; + // wrapping should not occur in the first round + if (i == 0) + p_ws = FALSE; + result = searchit(curwin, curbuf, &pos, &end_pos, (dir ? FORWARD : BACKWARD), spats[last_idx].pat, (long) (i ? count : 1), SEARCH_KEEP | flags, RE_SEARCH, NULL); + p_ws = old_p_ws; + /* First search may fail, but then start searching from the * beginning of the file (cursor might be on the search match) * except when Visual mode is active, so that extending the visual @@ -4822,7 +4822,6 @@ current_search( curwin->w_cursor = orig_pos; if (VIsual_active) VIsual = save_VIsual; - p_ws = old_p_ws; return FAIL; } else if (i == 0 && !result) @@ -4844,7 +4843,6 @@ current_search( } start_pos = pos; - p_ws = old_p_ws; if (!VIsual_active) VIsual = start_pos; diff --git a/src/testdir/test_gn.vim b/src/testdir/test_gn.vim index 9edf0a21e..098fc3db4 100644 --- a/src/testdir/test_gn.vim +++ b/src/testdir/test_gn.vim @@ -135,8 +135,9 @@ func Test_gn_command() call assert_equal(['ABCDEFGHi'], getline(1,'$')) call setline('.', ['abcdefghi']) let @/ = 'b' + " this gn wraps around the end of the file exe "norm! 0fhvhhgngU" - call assert_equal(['abcdefghi'], getline(1,'$')) + call assert_equal(['aBCDEFGHi'], getline(1,'$')) sil! %d _ call setline('.', ['abcdefghi']) let @/ = 'f' diff --git a/src/version.c b/src/version.c index 4b1acc5d7..5f009e316 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2244, +/**/ 2243, /**/ 2242, |