diff options
Diffstat (limited to 'src/nvim/ex_session.c')
-rw-r--r-- | src/nvim/ex_session.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index b11ec4ad05..67b8e7e92f 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -447,18 +447,25 @@ static int put_view( if (do_cursor) { // Restore the cursor line in the file and relatively in the // window. Don't use "G", it changes the jumplist. + if (wp->w_height_inner <= 0) { + if (fprintf(fd, "let s:l = %" PRIdLINENR "\n", wp->w_cursor.lnum) < 0) { + return FAIL; + } + } else if (fprintf(fd, + "let s:l = %" PRIdLINENR " - ((%" PRIdLINENR + " * winheight(0) + %" PRId64 ") / %" PRId64 ")\n", + wp->w_cursor.lnum, + wp->w_cursor.lnum - wp->w_topline, + (int64_t)(wp->w_height_inner / 2), + (int64_t)wp->w_height_inner) < 0) { + return FAIL; + } if (fprintf(fd, - "let s:l = %" PRId64 " - ((%" PRId64 - " * winheight(0) + %" PRId64 ") / %" PRId64 ")\n" "if s:l < 1 | let s:l = 1 | endif\n" "keepjumps exe s:l\n" "normal! zt\n" - "keepjumps %" PRId64 "\n", - (int64_t)wp->w_cursor.lnum, - (int64_t)(wp->w_cursor.lnum - wp->w_topline), - (int64_t)(wp->w_height_inner / 2), - (int64_t)wp->w_height_inner, - (int64_t)wp->w_cursor.lnum) < 0) { + "keepjumps %" PRIdLINENR "\n", + wp->w_cursor.lnum) < 0) { return FAIL; } // Restore the cursor column and left offset when not wrapping. @@ -718,7 +725,7 @@ static int makeopens(FILE *fd, char_u *dirnow) } } - if (tab_firstwin->w_next != NULL) { + if (tab_firstwin != NULL && tab_firstwin->w_next != NULL) { // Go to the first window. PUTLINE_FAIL("wincmd t"); @@ -828,7 +835,7 @@ static int makeopens(FILE *fd, char_u *dirnow) p_shm) < 0) { return FAIL; } - if (tab_firstwin->w_next != NULL) { + if (tab_firstwin != NULL && tab_firstwin->w_next != NULL) { // Restore 'winminheight' and 'winminwidth'. PUTLINE_FAIL("let &winminheight = s:save_winminheight"); PUTLINE_FAIL("let &winminwidth = s:save_winminwidth"); @@ -930,11 +937,13 @@ void ex_mkrc(exarg_T *eap) if (!view_session || (eap->cmdidx == CMD_mksession && (*flagp & SSOP_OPTIONS))) { - failed |= (makemap(fd, NULL) == FAIL - || makeset(fd, OPT_GLOBAL, false) == FAIL); - if (p_hls && fprintf(fd, "%s", "set hlsearch\n") < 0) { - failed = true; + int flags = OPT_GLOBAL; + + if (eap->cmdidx == CMD_mksession && (*flagp & SSOP_SKIP_RTP)) { + flags |= OPT_SKIPRTP; } + failed |= (makemap(fd, NULL) == FAIL + || makeset(fd, flags, false) == FAIL); } if (!failed && view_session) { @@ -995,6 +1004,9 @@ void ex_mkrc(exarg_T *eap) < 0) { failed = true; } + if (p_hls && fprintf(fd, "%s", "set hlsearch\n") < 0) { + failed = true; + } if (no_hlsearch && fprintf(fd, "%s", "nohlsearch\n") < 0) { failed = true; } |