To: vim_dev@googlegroups.com Subject: Patch 8.2.0984 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0984 Problem: Not using previous window when closing a shell popup window. Solution: Use "prevwin" if it was set. (closes #6267) Files: src/popupwin.c, src/testdir/test_popupwin.vim *** ../vim-8.2.0983/src/popupwin.c 2020-05-30 20:30:42.896816552 +0200 --- src/popupwin.c 2020-06-15 21:18:24.249750346 +0200 *************** *** 2148,2153 **** --- 2148,2166 ---- } /* + * Make "prevwin" the current window, unless it's equal to "wp". + * Otherwise make "firstwin" the current window. + */ + static void + back_to_prevwin(win_T *wp) + { + if (win_valid(prevwin) && wp != prevwin) + win_enter(prevwin, FALSE); + else + win_enter(firstwin, FALSE); + } + + /* * Close popup "wp" and invoke any close callback for it. */ static void *************** *** 2178,2187 **** break; if (owp != NULL) win_enter(owp, FALSE); - else if (win_valid(prevwin) && wp != prevwin) - win_enter(prevwin, FALSE); else ! win_enter(firstwin, FALSE); } } #endif --- 2191,2198 ---- break; if (owp != NULL) win_enter(owp, FALSE); else ! back_to_prevwin(wp); } } #endif *************** *** 2583,2589 **** error_for_popup_window(); return FAIL; } ! win_enter(firstwin, FALSE); } if (prev == NULL) first_popupwin = wp->w_next; --- 2594,2600 ---- error_for_popup_window(); return FAIL; } ! back_to_prevwin(wp); } if (prev == NULL) first_popupwin = wp->w_next; *************** *** 2620,2626 **** error_for_popup_window(); return FAIL; } ! win_enter(firstwin, FALSE); } if (prev == NULL) *root = wp->w_next; --- 2631,2637 ---- error_for_popup_window(); return FAIL; } ! back_to_prevwin(wp); } if (prev == NULL) *root = wp->w_next; *** ../vim-8.2.0983/src/testdir/test_popupwin.vim 2020-05-27 23:15:12.846004351 +0200 --- src/testdir/test_popupwin.vim 2020-06-15 21:17:39.725929635 +0200 *************** *** 2461,2466 **** --- 2461,2483 ---- call assert_equal(origwin, win_getid()) endfunc + func Test_popupwin_close_prevwin() + CheckFeature terminal + + call assert_equal(1, winnr('$')) + split + wincmd b + call assert_equal(2, winnr()) + let buf = term_start(&shell, #{hidden: 1}) + call popup_create(buf, {}) + call term_wait(buf, 100) + call popup_clear(1) + call assert_equal(2, winnr()) + + quit + exe 'bwipe! ' .. buf + endfunc + func Test_popupwin_with_buffer_and_filter() new Xwithfilter call setline(1, range(100)) *** ../vim-8.2.0983/src/version.c 2020-06-15 20:24:53.930811611 +0200 --- src/version.c 2020-06-15 21:06:14.560765771 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 984, /**/ -- Q: How many hardware engineers does it take to change a lightbulb? A: None. We'll fix it in software. /// 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 ///