Mercurial > vim
diff src/ex_cmds.c @ 14033:bcda3b864c31 v8.1.0034
patch 8.1.0034: cursor not restored with ":edit #"
commit https://github.com/vim/vim/commit/adb8fbec4f4059d214fe6acf2485ffd35e803450
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 4 20:34:23 2018 +0200
patch 8.1.0034: cursor not restored with ":edit #"
Problem: Cursor not restored with ":edit #".
Solution: Don't assume autocommands moved the cursor when it was moved to
the first non-blank.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 04 Jun 2018 20:45:06 +0200 |
parents | cec5137d5332 |
children | 2ad722003b36 |
line wrap: on
line diff
--- 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;