diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2015-12-16 05:21:30 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2015-12-16 05:24:38 +0900 |
commit | e1abbe6b679ec1190173f957363899afbb366717 (patch) | |
tree | c2c583d9057fc0b43f9b49703e39995de2053f82 /src | |
parent | 1946f96a16be42be3478c76585a25f08babb38df (diff) | |
download | rneovim-e1abbe6b679ec1190173f957363899afbb366717.tar.gz rneovim-e1abbe6b679ec1190173f957363899afbb366717.tar.bz2 rneovim-e1abbe6b679ec1190173f957363899afbb366717.zip |
vim-patch:7.4.675
Problem: When a FileReadPost autocommand moves the cursor inside a line it
gets moved back.
Solution: When checking whether an autocommand moved the cursor store the
column as well. (Christian Brabandt)
https://github.com/vim/vim/commit/eab316bdf9494eb1e076dfc5c8ec7ae000a0560f
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_cmds.c | 12 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d902234ef7..29cff5a2b2 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1989,7 +1989,7 @@ do_ecmd ( char_u *free_fname = NULL; int retval = FAIL; long n; - linenr_T lnum; + pos_T orig_pos; linenr_T topline = 0; int newcol = -1; int solcol = -1; @@ -2351,7 +2351,7 @@ do_ecmd ( * Careful: open_buffer() and apply_autocmds() may change the current * buffer and window. */ - lnum = curwin->w_cursor.lnum; + orig_pos = curwin->w_cursor; topline = curwin->w_topline; if (!oldbuf) { /* need to read the file */ swap_exists_action = SEA_DIALOG; @@ -2379,11 +2379,9 @@ do_ecmd ( } check_arg_idx(curwin); - /* - * If autocommands change the cursor position or topline, we should - * keep it. - */ - if (curwin->w_cursor.lnum != lnum) { + // If autocommands change the cursor position or topline, we should keep + // it. Also when it moves within a line. + if (!equalpos(curwin->w_cursor, orig_pos)) { newlnum = curwin->w_cursor.lnum; newcol = curwin->w_cursor.col; } diff --git a/src/nvim/version.c b/src/nvim/version.c index 662fcabf17..3d26f643dc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -318,7 +318,7 @@ static int included_patches[] = { // 678 NA // 677 NA // 676 NA - // 675, + 675, // 674 NA 673, // 672, |