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)

eab316bdf9
This commit is contained in:
Shougo Matsushita 2015-12-16 05:21:30 +09:00
parent 1946f96a16
commit e1abbe6b67
2 changed files with 6 additions and 8 deletions

View File

@ -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;
}

View File

@ -318,7 +318,7 @@ static int included_patches[] = {
// 678 NA
// 677 NA
// 676 NA
// 675,
675,
// 674 NA
673,
// 672,