Skip to content

Commit 9b2edfd

Browse files
LemonBoybrammool
authored andcommitted
patch 8.2.5002: deletebufline() may change Visual selection
Problem: deletebufline() may change Visual selection. Solution: Disable Visual mode when using another buffer. (closes #10469)
1 parent 8a37047 commit 9b2edfd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/evalbuffer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ f_deletebufline(typval_T *argvars, typval_T *rettv)
510510
tabpage_T *tp;
511511
win_T *wp;
512512
int did_emsg_before = did_emsg;
513+
int save_VIsual_active = VIsual_active;
513514

514515
rettv->vval.v_number = 1; // FAIL by default
515516

@@ -538,6 +539,7 @@ f_deletebufline(typval_T *argvars, typval_T *rettv)
538539

539540
if (!is_curbuf)
540541
{
542+
VIsual_active = FALSE;
541543
curbuf_save = curbuf;
542544
curwin_save = curwin;
543545
curbuf = buf;
@@ -582,6 +584,7 @@ f_deletebufline(typval_T *argvars, typval_T *rettv)
582584
{
583585
curbuf = curbuf_save;
584586
curwin = curwin_save;
587+
VIsual_active = save_VIsual_active;
585588
}
586589
rettv->vval.v_number = 0; // OK
587590
}

src/testdir/test_bufline.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,21 @@ func Test_setbufline_select_mode()
238238
bwipe!
239239
endfunc
240240

241+
func Test_deletebufline_select_mode()
242+
new
243+
call setline(1, ['foo', 'bar'])
244+
call feedkeys("j^v2l\<C-G>", 'nx')
245+
246+
let bufnr = bufadd('Xdummy')
247+
call bufload(bufnr)
248+
call setbufline(bufnr, 1, ['abc', 'def'])
249+
call deletebufline(bufnr, 1)
250+
251+
call feedkeys("x", 'nx')
252+
call assert_equal(['foo', 'x'], getline(1, 2))
253+
254+
exe "bwipe! " .. bufnr
255+
bwipe!
256+
endfunc
257+
241258
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
5002,
737739
/**/
738740
5001,
739741
/**/

0 commit comments

Comments
 (0)