Skip to content

Commit 99ad3a8

Browse files
committed
patch 9.0.1362: ml_get error when going to another tab
Problem: ml_get error when going to another tab. (Daniel J. Perry) Solution: Do not call update_topline() if "curwin" is invalid. (closes #11907)
1 parent dd60c36 commit 99ad3a8

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/testdir/test_tabpage.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,4 +872,19 @@ func Test_tabpage_alloc_failure()
872872
call assert_equal(1, tabpagenr('$'))
873873
endfunc
874874

875+
" this was giving ml_get errors
876+
func Test_tabpage_last_line()
877+
enew
878+
call setline(1, repeat(['a'], &lines + 5))
879+
$
880+
tabnew
881+
call setline(1, repeat(['b'], &lines + 20))
882+
$
883+
tabNext
884+
call assert_equal('a', getline('.'))
885+
886+
bwipe!
887+
bwipe!
888+
endfunc
889+
875890
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1362,
698700
/**/
699701
1361,
700702
/**/

src/window.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5273,15 +5273,15 @@ win_enter_ext(win_T *wp, int flags)
52735273
int curwin_invalid = (flags & WEE_CURWIN_INVALID);
52745274
int did_decrement = FALSE;
52755275

5276-
if (wp == curwin && !curwin_invalid) // nothing to do
5276+
if (wp == curwin && curwin_invalid == 0) // nothing to do
52775277
return FALSE;
52785278

52795279
#ifdef FEAT_JOB_CHANNEL
5280-
if (!curwin_invalid)
5280+
if (curwin_invalid == 0)
52815281
leaving_window(curwin);
52825282
#endif
52835283

5284-
if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS))
5284+
if (curwin_invalid == 0 && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS))
52855285
{
52865286
/*
52875287
* Be careful: If autocommands delete the window, return now.
@@ -5309,13 +5309,13 @@ win_enter_ext(win_T *wp, int flags)
53095309

53105310
// Might need to scroll the old window before switching, e.g., when the
53115311
// cursor was moved.
5312-
if (*p_spk == 'c')
5312+
if (*p_spk == 'c' && curwin_invalid == 0)
53135313
update_topline();
53145314

53155315
// may have to copy the buffer options when 'cpo' contains 'S'
53165316
if (wp->w_buffer != curbuf)
53175317
buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP);
5318-
if (!curwin_invalid)
5318+
if (curwin_invalid == 0)
53195319
{
53205320
prevwin = curwin; // remember for CTRL-W p
53215321
curwin->w_redr_status = TRUE;

0 commit comments

Comments
 (0)