Hi Andy!
On So, 26 Aug 2012, Andy Wokula wrote:
> Am 08.08.2012 15:40, schrieb Bram Moolenaar:
> Some pattern e.g. /\<t\w\+
>
> When
> Visual mode is on (charwise)
> and the cursor is at the end of the selection
> and the selection ends within the *first* pattern match in the buffer
> Then
> gn
> selects up to the end of the *next* match (2nd match in the buffer);
> beeps when there is no 2nd match (should select up to the end of the
> current match).
Ok, I see the problem. Originally, I tried to prevent, that when visual
mode is active and you are after the last match, the cursor would
visually select the first match. But this does not seem to happen
anymore with the attached patch.
>
> Works ok when on the 2nd match (and later matches).
>
>
> Rechecking with a minimal config (-N -u NONE -i NONE)
> I noticed one more issue
> gn
> (error, no previous regular expression)
> Then,
> /t\w\+
> (= some pattern) finds text, but
> gn
> still beeps.
I see the problem.
Please try the attached patch. If it works ok and you don't find any
more issues, I'll send it to Bram together with a test.
regards,
Christian
--
Organische Natur: Ins Kleinste lebendig; Kunst: Ins Kleinste
empfunden.
-- Goethe, Maximen und Reflektionen, Nr. 1363
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/search.c b/src/search.c
--- a/src/search.c
+++ b/src/search.c
@@ -4545,7 +4545,6 @@
int dir;
int result; /* result of various function calls */
char_u old_p_ws = p_ws;
- int visual_active = FALSE;
int flags = 0;
pos_T save_VIsual;
int zerowidth = FALSE;
@@ -4561,11 +4560,6 @@
{
orig_pos = curwin->w_cursor;
save_VIsual = VIsual;
- visual_active = TRUE;
-
- /* just started visual selection, only one character */
- if (equalpos(VIsual, curwin->w_cursor))
- visual_active = FALSE;
pos = curwin->w_cursor;
start_pos = VIsual;
@@ -4619,7 +4613,7 @@
p_ws = old_p_ws;
return FAIL;
}
- else if (!i && !result && !visual_active)
+ else if (!i && !result)
{
if (forward) /* try again from start of buffer */
{
@@ -4692,6 +4686,7 @@
int nmatched = 0;
int result = -1;
pos_T pos;
+ int save_called_emsg = called_emsg;
if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
SEARCH_KEEP, ®match) == FAIL)
@@ -4704,15 +4699,17 @@
{
/* Zero-width pattern should match somewhere, then we can check if
* start and end are in the same position. */
+ called_emsg = FALSE;
nmatched = vim_regexec_multi(®match, curwin, curbuf,
pos.lnum, (colnr_T)0, NULL);
if (!called_emsg)
result = (nmatched != 0
- && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
- && regmatch.startpos[0].col == regmatch.endpos[0].col);
+ && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
+ && regmatch.startpos[0].col == regmatch.endpos[0].col);
}
+ called_emsg |= save_called_emsg;
vim_free(regmatch.regprog);
return result;
}