aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/search.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-11-09 21:55:28 -0800
committerGitHub <noreply@github.com>2019-11-09 21:55:28 -0800
commit268252c8c729fa6076037c04966c0a6e694dab75 (patch)
treed9875962bdfe4fda3f83d5ca4b0475eab0525240 /src/nvim/search.c
parent7a23b67d3594ffb8b6d8629fd9ca1ef8147596db (diff)
parent099c38efed6cf5ca87dbff5c1d90a274991da4cf (diff)
downloadrneovim-268252c8c729fa6076037c04966c0a6e694dab75.tar.gz
rneovim-268252c8c729fa6076037c04966c0a6e694dab75.tar.bz2
rneovim-268252c8c729fa6076037c04966c0a6e694dab75.zip
Merge #11343 from janlazo/vim-8.1.2244
vim-patch:8.1.{324,1091,2244,2258,2262,2268,2270,2272}
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r--src/nvim/search.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index c4c8633ed9..d396e7551b 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -4037,9 +4037,6 @@ current_search(
bool old_p_ws = p_ws;
pos_T save_VIsual = VIsual;
- /* wrapping should not occur */
- p_ws = false;
-
/* Correct cursor when 'selection' is exclusive */
if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor))
dec_cursor();
@@ -4063,8 +4060,7 @@ current_search(
int 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 */
+ return FAIL; // pattern not found
}
/*
@@ -4081,11 +4077,18 @@ current_search(
}
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, 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
@@ -4094,7 +4097,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) {
if (forward) { // try again from start of buffer
@@ -4110,8 +4112,6 @@ current_search(
pos_T start_pos = pos;
- p_ws = old_p_ws;
-
if (!VIsual_active) {
VIsual = start_pos;
}