Make synstack() work on the character just after the end of the line.
diff --git a/src/undo.c b/src/undo.c
index 86b4d81..66a9ea0 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -233,6 +233,7 @@
/*
* Save the lines between "top" and "bot" for both the "u" and "U" command.
* "top" may be 0 and bot may be curbuf->b_ml.ml_line_count + 1.
+ * Careful: may trigger autocommands that reload the buffer.
* Returns FAIL when lines could not be saved, OK otherwise.
*/
int
@@ -255,6 +256,8 @@
/*
* Save the line "lnum" (used by ":s" and "~" command).
* The line is replaced, so the new bottom line is lnum + 1.
+ * Careful: may trigger autocommands that reload the buffer.
+ * Returns FAIL when lines could not be saved, OK otherwise.
*/
int
u_savesub(lnum)
@@ -269,6 +272,8 @@
/*
* A new line is inserted before line "lnum" (used by :s command).
* The line is inserted, so the new bottom line is lnum + 1.
+ * Careful: may trigger autocommands that reload the buffer.
+ * Returns FAIL when lines could not be saved, OK otherwise.
*/
int
u_inssub(lnum)
@@ -284,6 +289,8 @@
* Save the lines "lnum" - "lnum" + nlines (used by delete command).
* The lines are deleted, so the new bottom line is lnum, unless the buffer
* becomes empty.
+ * Careful: may trigger autocommands that reload the buffer.
+ * Returns FAIL when lines could not be saved, OK otherwise.
*/
int
u_savedel(lnum, nlines)
@@ -333,6 +340,10 @@
/*
* Common code for various ways to save text before a change.
+ * "top" is the line above the first changed line.
+ * "bot" is the line below the last changed line.
+ * Careful: may trigger autocommands that reload the buffer.
+ * Returns FAIL when lines could not be saved, OK otherwise.
*/
static int
u_savecommon(top, bot, newbot)
@@ -383,6 +394,13 @@
* (e.g., obtained from a source control system).
*/
change_warning(0);
+ if (bot > curbuf->b_ml.ml_line_count + 1)
+ {
+ /* This happens when the FileChangedRO autocommand changes the file in
+ * a way it becomes shorter. */
+ EMSG(_("E834: Line count changed unexpectedly"));
+ return FAIL;
+ }
#endif
size = bot - top - 1;
@@ -3165,6 +3183,7 @@
* Implementation of the "U" command.
* Differentiation from vi: "U" can be undone with the next "U".
* We also allow the cursor to be in another line.
+ * Careful: may trigger autocommands that reload the buffer.
*/
void
u_undoline()