diff options
author | Michael Ennen <mike.ennen@gmail.com> | 2016-11-24 23:59:10 -0700 |
---|---|---|
committer | Michael Ennen <mike.ennen@gmail.com> | 2016-11-25 18:23:36 -0700 |
commit | 22c7dbd5f886a5ec116a6863bb527d99f5152eeb (patch) | |
tree | b5e65a07c4c0cce50b1146472477b2faa70fbfbf | |
parent | 5f0260808cf3712718555ee177476b8aefd78280 (diff) | |
download | rneovim-22c7dbd5f886a5ec116a6863bb527d99f5152eeb.tar.gz rneovim-22c7dbd5f886a5ec116a6863bb527d99f5152eeb.tar.bz2 rneovim-22c7dbd5f886a5ec116a6863bb527d99f5152eeb.zip |
vim-patch:7.4.1711
Problem: When using try/catch in 'statusline' it is still considered an
error and the status line will be disabled.
Solution: Check did_emsg instead of called_emsg. (haya14busa, closes vim/vim#729)
https://github.com/vim/vim/commit/a742e084b677f76c67e9e52c4f9fb9ab24002e20
-rw-r--r-- | src/nvim/screen.c | 20 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_statusline.vim | 39 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
4 files changed, 51 insertions, 11 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cee3c62f43..591f781e0e 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 156604051d..dacea81a34 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -13,6 +13,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 8f3619f1e8..47967ebc9a 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, // 1709 NA // 1708, |