diff --git a/src/buffer.c b/src/buffer.c index 49db39d8f6..5b66228255 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2003,9 +2003,6 @@ enter_buffer(buf_T *buf) // mark cursor position as being invalid curwin->w_valid = 0; - buflist_setfpos(curbuf, curwin, curbuf->b_last_cursor.lnum, - curbuf->b_last_cursor.col, TRUE); - // Make sure the buffer is loaded. if (curbuf->b_ml.ml_mfp == NULL) // need to load the file { diff --git a/src/testdir/test_buffer.vim b/src/testdir/test_buffer.vim index e16a537ef2..90b7a9aa43 100644 --- a/src/testdir/test_buffer.vim +++ b/src/testdir/test_buffer.vim @@ -613,4 +613,31 @@ func Test_closed_buffer_still_in_window() %bw! endfunc +" Cursor position should be restored when switching to a buffer previously +" viewed in a window, regardless of whether it's visible in another one. +func Test_switch_to_previously_viewed_buffer() + set nostartofline + new Xviewbuf + call setline(1, range(1, 200)) + let oldwin = win_getid() + vsplit + + call cursor(100, 3) + edit Xotherbuf + buffer Xviewbuf + call assert_equal([0, 100, 3, 0], getpos('.')) + + exe win_id2win(oldwin) .. 'close' + setlocal bufhidden=hide + + call cursor(200, 3) + edit Xotherbuf + buffer Xviewbuf + call assert_equal([0, 200, 3, 0], getpos('.')) + + bwipe! Xotherbuf + bwipe! Xviewbuf + set startofline& +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 3f3f1e1b63..3e37609b08 100644 --- a/src/version.c +++ b/src/version.c @@ -719,6 +719,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1601, /**/ 1600, /**/