diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 5bf743c4df..a851cd5ed1 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4939,8 +4939,8 @@ void win_redr_status(win_T *wp) */ static void redraw_custom_statusline(win_T *wp) { - static int entered = FALSE; - int save_called_emsg = called_emsg; + static int entered = false; + int saved_did_emsg = did_emsg; /* When called recursively return. This can happen when the statusline * contains an expression that triggers a redraw. */ @@ -4948,18 +4948,18 @@ static void redraw_custom_statusline(win_T *wp) return; entered = TRUE; - called_emsg = FALSE; - win_redr_custom(wp, FALSE); - if (called_emsg) { - /* When there is an error disable the statusline, otherwise the - * display is messed up with errors and a redraw triggers the problem - * again and again. */ + did_emsg = false; + win_redr_custom(wp, false); + if (did_emsg) { + // When there is an error disable the statusline, otherwise the + // display is messed up with errors and a redraw triggers the problem + // again and again. set_string_option_direct((char_u *)"statusline", -1, (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR); } - called_emsg |= save_called_emsg; - entered = FALSE; + did_emsg |= saved_did_emsg; + entered = false; } /* diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 4e8cd54ce3..d75430ed8d 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -12,6 +12,7 @@ source test_menu.vim source test_options.vim source test_popup.vim source test_regexp_utf8.vim +source test_statusline.vim source test_syn_attr.vim source test_tabpage.vim source test_unlet.vim diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim new file mode 100644 index 0000000000..82898df92d --- /dev/null +++ b/src/nvim/testdir/test_statusline.vim @@ -0,0 +1,39 @@ +function! StatuslineWithCaughtError() + let s:func_in_statusline_called = 1 + try + call eval('unknown expression') + catch + endtry + return '' +endfunction + +function! StatuslineWithError() + let s:func_in_statusline_called = 1 + call eval('unknown expression') + return '' +endfunction + +function! Test_caught_error_in_statusline() + let s:func_in_statusline_called = 0 + set laststatus=2 + let statusline = '%{StatuslineWithCaughtError()}' + let &statusline = statusline + redrawstatus + call assert_true(s:func_in_statusline_called) + call assert_equal(statusline, &statusline) + set statusline= +endfunction + +function! Test_statusline_will_be_disabled_with_error() + let s:func_in_statusline_called = 0 + set laststatus=2 + let statusline = '%{StatuslineWithError()}' + try + let &statusline = statusline + redrawstatus + catch + endtry + call assert_true(s:func_in_statusline_called) + call assert_equal('', &statusline) + set statusline= +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index 65bd4cfcf7..e9bd1b7438 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -733,7 +733,7 @@ static int included_patches[] = { 1714, // 1713 NA 1712, - // 1711, + 1711, // 1710 NA // 1709 NA // 1708,