summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-04 20:34:23 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-04 20:34:23 +0200
commitadb8fbec4f4059d214fe6acf2485ffd35e803450 (patch)
tree6e91c9fd410bb086c611cd0f48cc18d611d1cb91 /src/ex_cmds.c
parentacb9effecc9f54b93398a44cc0ec40e77978e094 (diff)
patch 8.1.0034: cursor not restored with ":edit #"v8.1.0034
Problem: Cursor not restored with ":edit #". Solution: Don't assume autocommands moved the cursor when it was moved to the first non-blank.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 111fe01d22..60d72023c9 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4193,11 +4193,18 @@ do_ecmd(
check_arg_idx(curwin);
/* If autocommands change the cursor position or topline, we should
- * keep it. Also when it moves within a line. */
+ * keep it. Also when it moves within a line. But not when it moves
+ * to the first non-blank. */
if (!EQUAL_POS(curwin->w_cursor, orig_pos))
{
- newlnum = curwin->w_cursor.lnum;
- newcol = curwin->w_cursor.col;
+ char_u *text = ml_get_curline();
+
+ if (curwin->w_cursor.lnum != orig_pos.lnum
+ || curwin->w_cursor.col != (int)(skipwhite(text) - text))
+ {
+ newlnum = curwin->w_cursor.lnum;
+ newcol = curwin->w_cursor.col;
+ }
}
if (curwin->w_topline == topline)
topline = 0;