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.
diff --git a/src/autocmd.c b/src/autocmd.c
index 862370f..37f2480 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -1424,8 +1424,6 @@
if (call_do_modelines && did_aucmd)
do_modelines(0);
}
-
- check_cursor(); // just in case lines got deleted
}
/*
@@ -1532,6 +1530,10 @@
curbuf = buf;
aco->new_curwin_id = curwin->w_id;
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 @@
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;
diff --git a/src/structs.h b/src/structs.h
index 197df72..9d57681 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4031,6 +4031,7 @@
int save_prevwin_id; // ID of saved prevwin
bufref_T new_curbuf; // new curbuf
char_u *globaldir; // saved value of globaldir
+ int save_VIsual_active; // saved VIsual_active
} aco_save_T;
/*
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index b6f621d..1fc960f 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
Binary files differ
diff --git a/src/version.c b/src/version.c
index 731f8ce..53202e5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4028,
+/**/
4027,
/**/
4026,