mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.1.2244: 'wrapscan' is not used for "gn"
Problem: 'wrapscan' is not used for "gn". Solution: Only reset 'wrapscan' for the first search round. (closes #5164)
This commit is contained in:
14
src/search.c
14
src/search.c
@@ -4765,9 +4765,6 @@ current_search(
|
|||||||
pos_T save_VIsual = VIsual;
|
pos_T save_VIsual = VIsual;
|
||||||
int zero_width;
|
int zero_width;
|
||||||
|
|
||||||
/* wrapping should not occur */
|
|
||||||
p_ws = FALSE;
|
|
||||||
|
|
||||||
/* Correct cursor when 'selection' is exclusive */
|
/* Correct cursor when 'selection' is exclusive */
|
||||||
if (VIsual_active && *p_sel == 'e' && LT_POS(VIsual, curwin->w_cursor))
|
if (VIsual_active && *p_sel == 'e' && LT_POS(VIsual, curwin->w_cursor))
|
||||||
dec_cursor();
|
dec_cursor();
|
||||||
@@ -4786,10 +4783,7 @@ current_search(
|
|||||||
zero_width = is_zero_width(spats[last_idx].pat, TRUE, &curwin->w_cursor,
|
zero_width = is_zero_width(spats[last_idx].pat, TRUE, &curwin->w_cursor,
|
||||||
FORWARD);
|
FORWARD);
|
||||||
if (zero_width == -1)
|
if (zero_width == -1)
|
||||||
{
|
|
||||||
p_ws = old_p_ws;
|
|
||||||
return FAIL; /* pattern not found */
|
return FAIL; /* pattern not found */
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The trick is to first search backwards and then search forward again,
|
* The trick is to first search backwards and then search forward again,
|
||||||
@@ -4808,11 +4802,17 @@ current_search(
|
|||||||
flags = SEARCH_END;
|
flags = SEARCH_END;
|
||||||
end_pos = pos;
|
end_pos = pos;
|
||||||
|
|
||||||
|
// wrapping should not occur in the first round
|
||||||
|
if (i == 0)
|
||||||
|
p_ws = FALSE;
|
||||||
|
|
||||||
result = searchit(curwin, curbuf, &pos, &end_pos,
|
result = searchit(curwin, curbuf, &pos, &end_pos,
|
||||||
(dir ? FORWARD : BACKWARD),
|
(dir ? FORWARD : BACKWARD),
|
||||||
spats[last_idx].pat, (long) (i ? count : 1),
|
spats[last_idx].pat, (long) (i ? count : 1),
|
||||||
SEARCH_KEEP | flags, RE_SEARCH, NULL);
|
SEARCH_KEEP | flags, RE_SEARCH, NULL);
|
||||||
|
|
||||||
|
p_ws = old_p_ws;
|
||||||
|
|
||||||
/* First search may fail, but then start searching from the
|
/* First search may fail, but then start searching from the
|
||||||
* beginning of the file (cursor might be on the search match)
|
* beginning of the file (cursor might be on the search match)
|
||||||
* except when Visual mode is active, so that extending the visual
|
* except when Visual mode is active, so that extending the visual
|
||||||
@@ -4822,7 +4822,6 @@ current_search(
|
|||||||
curwin->w_cursor = orig_pos;
|
curwin->w_cursor = orig_pos;
|
||||||
if (VIsual_active)
|
if (VIsual_active)
|
||||||
VIsual = save_VIsual;
|
VIsual = save_VIsual;
|
||||||
p_ws = old_p_ws;
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
else if (i == 0 && !result)
|
else if (i == 0 && !result)
|
||||||
@@ -4844,7 +4843,6 @@ current_search(
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_pos = pos;
|
start_pos = pos;
|
||||||
p_ws = old_p_ws;
|
|
||||||
|
|
||||||
if (!VIsual_active)
|
if (!VIsual_active)
|
||||||
VIsual = start_pos;
|
VIsual = start_pos;
|
||||||
|
@@ -135,8 +135,9 @@ func Test_gn_command()
|
|||||||
call assert_equal(['ABCDEFGHi'], getline(1,'$'))
|
call assert_equal(['ABCDEFGHi'], getline(1,'$'))
|
||||||
call setline('.', ['abcdefghi'])
|
call setline('.', ['abcdefghi'])
|
||||||
let @/ = 'b'
|
let @/ = 'b'
|
||||||
|
" this gn wraps around the end of the file
|
||||||
exe "norm! 0fhvhhgngU"
|
exe "norm! 0fhvhhgngU"
|
||||||
call assert_equal(['abcdefghi'], getline(1,'$'))
|
call assert_equal(['aBCDEFGHi'], getline(1,'$'))
|
||||||
sil! %d _
|
sil! %d _
|
||||||
call setline('.', ['abcdefghi'])
|
call setline('.', ['abcdefghi'])
|
||||||
let @/ = 'f'
|
let @/ = 'f'
|
||||||
|
@@ -741,6 +741,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2244,
|
||||||
/**/
|
/**/
|
||||||
2243,
|
2243,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user