To: vim_dev@googlegroups.com Subject: Patch 8.1.1832 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1832 Problem: Win_execute() does not work in other tab. (Rick Howe) Solution: Take care of the tab. (closes #4792) Files: src/testdir/test_execute_func.vim, src/evalfunc.c, src/window.c, src/proto/window.pro *** ../vim-8.1.1831/src/testdir/test_execute_func.vim 2019-06-01 17:06:22.688018611 +0200 --- src/testdir/test_execute_func.vim 2019-08-09 14:45:42.271913191 +0200 *************** *** 100,102 **** --- 100,111 ---- call win_gotoid(otherwin) bwipe! endfunc + + func Test_win_execute_other_tab() + let thiswin = win_getid() + tabnew + call win_execute(thiswin, 'let xyz = 1') + call assert_equal(1, xyz) + tabclose + unlet xyz + endfunc *** ../vim-8.1.1831/src/evalfunc.c 2019-08-06 21:59:37.759982504 +0200 --- src/evalfunc.c 2019-08-09 14:54:01.413082532 +0200 *************** *** 5726,5739 **** f_win_execute(typval_T *argvars, typval_T *rettv) { int id = (int)tv_get_number(argvars); ! win_T *wp = win_id2wp(id); win_T *save_curwin; tabpage_T *save_curtab; ! if (wp != NULL) { ! if (switch_win_noblock(&save_curwin, &save_curtab, wp, curtab, TRUE) ! == OK) { check_cursor(); execute_common(argvars, rettv, 1); --- 5726,5739 ---- f_win_execute(typval_T *argvars, typval_T *rettv) { int id = (int)tv_get_number(argvars); ! tabpage_T *tp; ! win_T *wp = win_id2wp_tp(id, &tp); win_T *save_curwin; tabpage_T *save_curtab; ! if (wp != NULL && tp != NULL) { ! if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE) == OK) { check_cursor(); execute_common(argvars, rettv, 1); *** ../vim-8.1.1831/src/window.c 2019-07-27 17:31:33.028355333 +0200 --- src/window.c 2019-08-09 14:52:05.137682901 +0200 *************** *** 6887,6910 **** --- 6887,6934 ---- list_append_number(list, 0); } + /* + * Return the window pointer of window "id". + */ win_T * win_id2wp(int id) { + return win_id2wp_tp(id, NULL); + } + + /* + * Return the window and tab pointer of window "id". + */ + win_T * + win_id2wp_tp(int id, tabpage_T **tpp) + { win_T *wp; tabpage_T *tp; FOR_ALL_TAB_WINDOWS(tp, wp) if (wp->w_id == id) + { + if (tpp != NULL) + *tpp = tp; return wp; + } #ifdef FEAT_TEXT_PROP // popup windows are in separate lists FOR_ALL_TABPAGES(tp) for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_id == id) + { + if (tpp != NULL) + *tpp = tp; return wp; + } for (wp = first_popupwin; wp != NULL; wp = wp->w_next) if (wp->w_id == id) + { + if (tpp != NULL) + *tpp = tp; return wp; + } #endif return NULL; *** ../vim-8.1.1831/src/proto/window.pro 2019-07-22 23:03:53.322360395 +0200 --- src/proto/window.pro 2019-08-09 14:52:25.017581473 +0200 *************** *** 90,95 **** --- 90,96 ---- int win_gotoid(typval_T *argvars); void win_id2tabwin(typval_T *argvars, list_T *list); win_T *win_id2wp(int id); + win_T *win_id2wp_tp(int id, tabpage_T **tpp); int win_id2win(typval_T *argvars); void win_findbuf(typval_T *argvars, list_T *list); void get_framelayout(frame_T *fr, list_T *l, int outer); *** ../vim-8.1.1831/src/version.c 2019-08-09 14:13:54.789278493 +0200 --- src/version.c 2019-08-09 14:46:53.563479597 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1832, /**/ -- Everyone has a photographic memory. Some don't have film. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///