Skip to content

Commit e71c0eb

Browse files
committed
patch 8.2.2911: pattern "\%V" does not match all of block selection
Problem: Pattern "\%V" does not match all of block selection. (Rick Howe) Solution: Use the value of vi_curswant. (closes #8285)
1 parent 0b49648 commit e71c0eb

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/regexp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ reg_match_visual(void)
12791279
colnr_T start, end;
12801280
colnr_T start2, end2;
12811281
colnr_T cols;
1282+
colnr_T curswant;
12821283

12831284
// Check if the buffer is the current buffer.
12841285
if (rex.reg_buf != curbuf || VIsual.lnum == 0)
@@ -1297,6 +1298,7 @@ reg_match_visual(void)
12971298
bot = VIsual;
12981299
}
12991300
mode = VIsual_mode;
1301+
curswant = wp->w_curswant;
13001302
}
13011303
else
13021304
{
@@ -1311,6 +1313,7 @@ reg_match_visual(void)
13111313
bot = curbuf->b_visual.vi_start;
13121314
}
13131315
mode = curbuf->b_visual.vi_mode;
1316+
curswant = curbuf->b_visual.vi_curswant;
13141317
}
13151318
lnum = rex.lnum + rex.reg_firstlnum;
13161319
if (lnum < top.lnum || lnum > bot.lnum)
@@ -1331,7 +1334,7 @@ reg_match_visual(void)
13311334
start = start2;
13321335
if (end2 > end)
13331336
end = end2;
1334-
if (top.col == MAXCOL || bot.col == MAXCOL)
1337+
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)
13351338
end = MAXCOL;
13361339
cols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));
13371340
if (cols < start || cols > end - (*p_sel == 'e'))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
|a+0&#ffff4012@1| | +0&#ffffff0@56
2+
>b+0&#ffff4012@3| | +0&#ffffff0@54
3+
|c+0&#ffff4012@5| | +0&#ffffff0@52
4+
|~+0#4040ff13&| @58
5+
|~| @58
6+
|~| @58
7+
|~| @58
8+
|~| @58
9+
|/+0#0000000&|\|%|V| @37|2|,|1| @10|A|l@1|

src/testdir/test_search.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,26 @@ func Test_hlsearch_and_visual()
984984
call delete('Xhlvisual_script')
985985
endfunc
986986

987+
func Test_hlsearch_block_visual_match()
988+
CheckScreendump
989+
990+
let lines =<< trim END
991+
set hlsearch
992+
call setline(1, ['aa', 'bbbb', 'cccccc'])
993+
END
994+
call writefile(lines, 'Xhlsearch_block')
995+
let buf = RunVimInTerminal('-S Xhlsearch_block', {'rows': 9, 'cols': 60})
996+
997+
call term_sendkeys(buf, "G\<C-V>$kk\<Esc>")
998+
sleep 100m
999+
call term_sendkeys(buf, "/\\%V\<CR>")
1000+
sleep 100m
1001+
call VerifyScreenDump(buf, 'Test_hlsearch_block_visual_match', {})
1002+
1003+
call StopVimInTerminal(buf)
1004+
call delete('Xhlsearch_block')
1005+
endfunc
1006+
9871007
func Test_incsearch_substitute()
9881008
CheckOption incsearch
9891009

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2911,
753755
/**/
754756
2910,
755757
/**/

0 commit comments

Comments
 (0)