]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2340: win_execute() unexpectedly returns number zero when failing v8.2.2340
authorBram Moolenaar <Bram@vim.org>
Tue, 12 Jan 2021 21:08:53 +0000 (22:08 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 12 Jan 2021 21:08:53 +0000 (22:08 +0100)
Problem:    win_execute() unexpectedly returns number zero when failing.
Solution:   Return an empty string. (closes #7665)

src/evalwindow.c
src/testdir/test_execute_func.vim
src/testdir/test_vim9_builtin.vim
src/version.c

index 492269ede430f66874c3d6400d113fc8ad85e79f..e00747a2de56a78749dbd72a067c284f2935554d 100644 (file)
@@ -673,6 +673,10 @@ f_win_execute(typval_T *argvars, typval_T *rettv)
     win_T      *save_curwin;
     tabpage_T  *save_curtab;
 
+    // Return an empty string if something fails.
+    rettv->v_type = VAR_STRING;
+    rettv->vval.v_string = NULL;
+
     if (wp != NULL && tp != NULL)
     {
        pos_T   curpos = wp->w_cursor;
index e02b08eb4bc387bd791b7dfd436891a70e07a937..036371715c325e0047c0118c9622bb7e7de03e84 100644 (file)
@@ -89,6 +89,8 @@ func Test_win_execute()
   call win_gotoid(thiswin)
   let line = win_execute(otherwin, 'echo getline(1)')
   call assert_match('the new window', line)
+  let line = win_execute(134343, 'echo getline(1)')
+  call assert_equal('', line)
 
   if has('popupwin')
     let popupwin = popup_create('the popup win', {'line': 2, 'col': 3})
index a84b7f6210482637241604687c369cf83b046a83..40cfdcbb14378c67f629cbbbe9394747ff053434 100644 (file)
@@ -800,6 +800,11 @@ def Test_timer_paused()
   timer_stop(id)
 enddef
 
+def Test_win_execute()
+  assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()'))
+  assert_equal('', win_execute(342343, 'echo winnr()'))
+enddef
+
 def Test_win_splitmove()
   split
   win_splitmove(1, 2, {vertical: true, rightbelow: true})
index fe41ec27a0a684da4345bca07c004399dd1cf58b..24462a0e678af5ca9e94a7b5d49a140356c6562c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2340,
 /**/
     2339,
 /**/