aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-09-12 07:36:28 +0200
committerGitHub <noreply@github.com>2018-09-12 07:36:28 +0200
commit931e15471c10857af73aa0f0caa3aaaefe5986be (patch)
tree08d50983aa75fb9960bd3f4cc5c79af6bc5d5254 /src/nvim/ex_cmds.c
parent61df24b9982c26c068e5fafbc79fd059a067d998 (diff)
parente15c34fbc29b4d98566f80a0d65436081a32e5b5 (diff)
downloadrneovim-931e15471c10857af73aa0f0caa3aaaefe5986be.tar.gz
rneovim-931e15471c10857af73aa0f0caa3aaaefe5986be.tar.bz2
rneovim-931e15471c10857af73aa0f0caa3aaaefe5986be.zip
Merge #8984 from janlazo/vim-8.1.0034
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index ac5b3af459..b700d780c7 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2546,11 +2546,17 @@ int 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.
+ // If autocommands change the cursor position or topline, we should
+ // keep it. Also when it moves within a line. But not when it moves
+ // to the first non-blank.
if (!equalpos(curwin->w_cursor, orig_pos)) {
- newlnum = curwin->w_cursor.lnum;
- newcol = curwin->w_cursor.col;
+ const char_u *text = get_cursor_line_ptr();
+
+ 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;