Hi James!
On Mo, 08 Nov 2010, James Vega wrote:
> On Mon, Nov 8, 2010 at 3:34 PM, Christian Brabandt <[email protected]> wrote:
> > On Fr, 05 Nov 2010, Benjamin R. Haskell wrote:
> >> Removing the optionality, it's also weird, as the trailing space
> >> (singular!?) isn't matched:
> >>
> >> /\%V\S\+\s*\%V
> >> xxxxx VVV VVV VVV xxxxx - text
> >> mmmmmmmmmmmm - match
> >> xxxxx VVV xxxxx - text
> >> mmmm - match
> >>
> >> Can anyone shed some light on this?
> > This is a bug. The regular expression engine is quite complex in Vim. I
> > think, the attached patch fixes it.
>
> What I see with your patch is that end of the match is including the
> first non-whitespace character after the end of the whitespace sequence.
> This means all matches other than the first start on the second
> non-whitespace character in the \S sequence and if the last
> non-whitespace sequence is only one character, the subsequent whitespace
> sequence won't be matched.
>
> Using the style from above (with alternating case for 'm' indicating the
> distinct matches):
>
> xxxxx VVV VVV V xxxx - text
> mmmmmMMMM - match
>
> Also, I see inconsistent highlighting with 'incsearch' enabled when the
> user has typed part of an escape sequence (e.g., '\' or '\%'). The
> highlighting for every line below some arbitrary line completely
> disappears until the escape sequence is completed. Performing a
> ":redraw!" or "/<Up>" may also trigger this.
>
> If this happens while typing the search string, complete the escape
> sequence, backspace to make it incomplete, complete it, etc. You'll see
> the portion of the file that's properly syntax highlighted increase
> every time you change the (in)complete status of the escape sequence.
>
> Not sure if it's related, but the patch also introduces this warning:
>
> regexp.c: In function ‘regtry’:
> regexp.c:3741: warning: comparison between pointer and integer
Here is another patch, including a basic test, that should address all
the issues. I couldn't reproduce the highlighting problem, though. This
seems to work ok for me now for the test cases I could imagine.
regards,
Christian
--
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/regexp.c b/src/regexp.c
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -3061,6 +3061,7 @@
static linenr_T reglnum; /* line number, relative to first line */
static char_u *regline; /* start of current line */
static char_u *reginput; /* current input, points into "regline" */
+static int need_adv_col; /* adjust end column after visual match */
static int need_clear_subexpr; /* subexpressions still need to be
* cleared */
@@ -3719,11 +3720,15 @@
{
reg_startpos[0].lnum = 0;
reg_startpos[0].col = col;
+
}
if (reg_endpos[0].lnum < 0)
{
reg_endpos[0].lnum = reglnum;
reg_endpos[0].col = (int)(reginput - regline);
+ if (reg_endpos[0].col == need_adv_col
+ && reg_endpos[0].col == curbuf->b_visual.vi_end.col)
+ reg_endpos[0].col++;
}
else
/* Use line number of "\ze". */
@@ -3735,6 +3740,9 @@
reg_startp[0] = regline + col;
if (reg_endp[0] == NULL)
reg_endp[0] = reginput;
+ if ((int)reg_endp[0] == need_adv_col
+ && (int)need_adv_col == curbuf->b_visual.vi_end.col)
+ reg_endp[0]++;
}
#ifdef FEAT_SYN_HL
/* Package any found \z(...\) matches for export. Default is none. */
@@ -4012,6 +4020,7 @@
}
lnum = reglnum + reg_firstlnum;
col = (colnr_T)(reginput - regline);
+ need_adv_col = col;
if (lnum < top.lnum || lnum > bot.lnum)
status = RA_NOMATCH;
else if (mode == 'v')
@@ -4019,6 +4028,7 @@
if ((lnum == top.lnum && col < top.col)
|| (lnum == bot.lnum
&& col >= bot.col + (*p_sel != 'e')))
+ //&& col >= bot.col + (*p_sel != 'e')))
status = RA_NOMATCH;
}
else if (mode == Ctrl_V)
diff --git a/src/testdir/Make_amiga.mak b/src/testdir/Make_amiga.mak
--- a/src/testdir/Make_amiga.mak
+++ b/src/testdir/Make_amiga.mak
@@ -28,7 +28,7 @@
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out test73.out test74.out test75.out \
- test76.out
+ test76.out test77.out
.SUFFIXES: .in .out
diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak
--- a/src/testdir/Make_dos.mak
+++ b/src/testdir/Make_dos.mak
@@ -28,7 +28,7 @@
test37.out test38.out test39.out test40.out test41.out \
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out test71.out test72.out test73.out \
- test74.out test75.out test76.out
+ test74.out test75.out test76.out test77.out
SCRIPTS32 = test50.out test70.out
diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -48,7 +48,7 @@
test37.out test38.out test39.out test40.out test41.out \
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out test71.out test72.out test73.out \
- test74.out test75.out test76.out
+ test74.out test75.out test76.out test77.out
SCRIPTS32 = test50.out test70.out
diff --git a/src/testdir/Make_os2.mak b/src/testdir/Make_os2.mak
--- a/src/testdir/Make_os2.mak
+++ b/src/testdir/Make_os2.mak
@@ -28,7 +28,7 @@
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out test73.out test74.out test75.out \
- test76.out
+ test76.out test77.out
.SUFFIXES: .in .out
diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -74,7 +74,8 @@
test56.out test57.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out \
- test71.out test72.out test74.out test75.out test76.out
+ test71.out test72.out test74.out test75.out test76.out \
+ test77.out
# Known problems:
# Test 30: a problem around mac format - unknown reason
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -25,7 +25,7 @@
test59.out test60.out test61.out test62.out test63.out \
test64.out test65.out test66.out test67.out test68.out \
test69.out test70.out test71.out test72.out test73.out \
- test74.out test75.out test76.out
+ test74.out test75.out test76.out test77.out
SCRIPTS_GUI = test16.out
diff --git a/src/testdir/test77.in b/src/testdir/test77.in
new file mode 100644
--- /dev/null
+++ b/src/testdir/test77.in
@@ -0,0 +1,37 @@
+Tests for Regular Expressions. vim: set ft=vim :
+
+STARTTEST
+:"Test regular expressions
+:so small.vim
+:function! RETestVisual()
+: /11111
+: exe "norm! /VVV VVV [V] \<CR>"
+: ks
+: exe "norm! v//e\<CR>\<ESC>"
+: norm! `a
+: exe "norm! /\\%V\\S\\+\\s*\\%V\<CR>"
+: exe "norm! \"ay//e\<CR>"
+: exe "norm! /\\%V\\S\\+\\s*\\%V\<CR>"
+: exe "norm! \"by//e\<CR>"
+: exe "norm! /\\%V\\S\\+\\s*\\%V\<CR>"
+: exe "norm! \"cy//e\<CR>"
+: put a
+: put b
+: put c
+: /22222
+: exe "norm! /[F]OOBAR\<CR>"
+: exe "norm! v//e\<CR>\<ESC>"
+: exe "norm! /\\%V.*\\%V\<CR>"
+: exe "norm! \"dy//e\<CR>"
+: put d
+:endfun
+:call RETestVisual()
+:/^+++/,$w! test.out
+:qa!
+ENDTEST
+
++++
+11111
+xxxxxVVV VVV V xxxx
+22222
+ |FOOBAR |
diff --git a/src/testdir/test77.ok b/src/testdir/test77.ok
new file mode 100644
--- /dev/null
+++ b/src/testdir/test77.ok
@@ -0,0 +1,9 @@
++++
+11111
+xxxxxVVV VVV V xxxx
+VVV
+VVV
+V
+22222
+ |FOOBAR |
+FOOBAR