[vim] 23/139: 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 #729)

James McCoy jamessan at debian.org
Fri May 6 03:59:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch debian/sid
in repository vim.

commit a742e084b677f76c67e9e52c4f9fb9ab24002e20
Author: Bram Moolenaar <Bram at vim.org>
Date:   Tue Apr 5 21:10:38 2016 +0200

    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 #729)
---
 src/screen.c                    |  8 ++++----
 src/testdir/test_alot.vim       |  1 +
 src/testdir/test_statusline.vim | 39 +++++++++++++++++++++++++++++++++++++++
 src/version.c                   |  2 ++
 4 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/screen.c b/src/screen.c
index 4c2b70c..dc5d175 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -6779,7 +6779,7 @@ win_redr_status(win_T *wp)
 redraw_custom_statusline(win_T *wp)
 {
     static int	    entered = FALSE;
-    int		    save_called_emsg = called_emsg;
+    int		    saved_did_emsg = did_emsg;
 
     /* When called recursively return.  This can happen when the statusline
      * contains an expression that triggers a redraw. */
@@ -6787,9 +6787,9 @@ redraw_custom_statusline(win_T *wp)
 	return;
     entered = TRUE;
 
-    called_emsg = FALSE;
+    did_emsg = FALSE;
     win_redr_custom(wp, FALSE);
-    if (called_emsg)
+    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
@@ -6798,7 +6798,7 @@ redraw_custom_statusline(win_T *wp)
 		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
 					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
     }
-    called_emsg |= save_called_emsg;
+    did_emsg |= saved_did_emsg;
     entered = FALSE;
 }
 #endif
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
index 4ee331f..1eb76a6 100644
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -22,6 +22,7 @@ source test_reltime.vim
 source test_searchpos.vim
 source test_set.vim
 source test_sort.vim
+source test_statusline.vim
 source test_syn_attr.vim
 source test_timers.vim
 source test_undolevels.vim
diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim
new file mode 100644
index 0000000..82898df
--- /dev/null
+++ b/src/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/version.c b/src/version.c
index 571db82..e254652 100644
--- a/src/version.c
+++ b/src/version.c
@@ -749,6 +749,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1711,
+/**/
     1710,
 /**/
     1709,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-vim/vim.git



More information about the pkg-vim-maintainers mailing list