From bd7371f4605032f015df9ab76ab5b25d61854932 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 2 Sep 2018 23:01:52 -0400 Subject: vim-patch:8.1.0333: :mkview does not restore cursor properly after "$" Problem: :mkview does not restore cursor properly after "$". (Dominique Pelle) Solution: Position the cursor with "normal! $". https://github.com/vim/vim/commit/92c1b696413bf0e28f2fec22090d42e8a825eff2 --- src/nvim/ex_docmd.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5a92a85c97..abefca231c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9239,6 +9239,18 @@ static int ses_do_win(win_T *wp) return true; } +static int put_view_curpos(FILE *fd, const win_T *wp, char *spaces) +{ + int r; + + if (wp->w_curswant == MAXCOL) { + r = fprintf(fd, "%snormal! $", spaces); + } else { + r = fprintf(fd, "%snormal! 0%d|", spaces, wp->w_virtcol + 1); + } + return r < 0 || put_eol(fd) == FAIL ? FAIL : OK; +} + /* * Write commands to "fd" to restore the view of a window. * Caller must make sure 'scrolloff' is zero. @@ -9405,14 +9417,11 @@ put_view( (int64_t)(wp->w_virtcol + 1)) < 0 || put_eol(fd) == FAIL || put_line(fd, "else") == FAIL - || fprintf(fd, " normal! 0%d|", wp->w_virtcol + 1) < 0 - || put_eol(fd) == FAIL + || put_view_curpos(fd, wp, " ") == FAIL || put_line(fd, "endif") == FAIL) return FAIL; - } else { - if (fprintf(fd, "normal! 0%d|", wp->w_virtcol + 1) < 0 - || put_eol(fd) == FAIL) - return FAIL; + } else if (put_view_curpos(fd, wp, "") == FAIL) { + return FAIL; } } } -- cgit