summaryrefslogtreecommitdiff
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-29 21:42:42 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-29 21:42:42 +0200
commit92c1b696413bf0e28f2fec22090d42e8a825eff2 (patch)
tree7f2e3d6d9e4fab5a519487090789ee1b5f98e869 /src/ex_docmd.c
parenta449a7c6b986b8f5b28c61b8f628e69ed43ca030 (diff)
downloadvim-git-92c1b696413bf0e28f2fec22090d42e8a825eff2.tar.gz
patch 8.1.0333: :mkview does not restore cursor properly after "$"v8.1.0333
Problem: :mkview does not restore cursor properly after "$". (Dominique Pelle) Solution: Position the cursor with "normal! $".
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index d4cf6a2c0..c8a1c3f23 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -11706,6 +11706,18 @@ ses_do_win(win_T *wp)
return TRUE;
}
+ static int
+put_view_curpos(FILE *fd, 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 ? FALSE : OK;
+}
+
/*
* Write commands to "fd" to restore the view of a window.
* Caller must make sure 'scrolloff' is zero.
@@ -11897,17 +11909,12 @@ put_view(
(long)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;
}
}