0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.4028: ml_get error with :doautoall and Visual area

Problem:    ml_get error with :doautoall and Visual area. (Sean Dewar)
Solution:   Disable Visual mode while executing autocommands.
This commit is contained in:
Bram Moolenaar
2022-01-07 15:45:18 +00:00
parent 2b04d5f1ef
commit cb1956d6f2
4 changed files with 22 additions and 2 deletions

View File

@@ -1424,8 +1424,6 @@ ex_doautoall(exarg_T *eap)
if (call_do_modelines && did_aucmd) if (call_do_modelines && did_aucmd)
do_modelines(0); do_modelines(0);
} }
check_cursor(); // just in case lines got deleted
} }
/* /*
@@ -1532,6 +1530,10 @@ aucmd_prepbuf(
curbuf = buf; curbuf = buf;
aco->new_curwin_id = curwin->w_id; aco->new_curwin_id = curwin->w_id;
set_bufref(&aco->new_curbuf, curbuf); set_bufref(&aco->new_curbuf, curbuf);
// disable the Visual area, the position may be invalid in another buffer
aco->save_VIsual_active = VIsual_active;
VIsual_active = FALSE;
} }
/* /*
@@ -1656,6 +1658,11 @@ win_found:
check_cursor(); check_cursor();
} }
} }
check_cursor(); // just in case lines got deleted
VIsual_active = aco->save_VIsual_active;
if (VIsual_active)
check_pos(curbuf, &VIsual);
} }
static int autocmd_nested = FALSE; static int autocmd_nested = FALSE;

View File

@@ -4031,6 +4031,7 @@ typedef struct
int save_prevwin_id; // ID of saved prevwin int save_prevwin_id; // ID of saved prevwin
bufref_T new_curbuf; // new curbuf bufref_T new_curbuf; // new curbuf
char_u *globaldir; // saved value of globaldir char_u *globaldir; // saved value of globaldir
int save_VIsual_active; // saved VIsual_active
} aco_save_T; } aco_save_T;
/* /*

View File

@@ -2812,6 +2812,16 @@ func Test_close_autocmd_tab()
%bwipe! %bwipe!
endfunc endfunc
func Test_Visual_doautoall_redraw()
call setline(1, ['a', 'b'])
new
wincmd p
call feedkeys("G\<C-V>", 'txn')
autocmd User Explode ++once redraw
doautoall User Explode
%bwipe!
endfunc
" This was using freed memory. " This was using freed memory.
func Test_BufNew_arglocal() func Test_BufNew_arglocal()
arglocal arglocal

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4028,
/**/ /**/
4027, 4027,
/**/ /**/