Mercurial > vim
changeset 20865:0e4cf74642a3 v8.2.0984
patch 8.2.0984: not using previous window when closing a shell popup window
Commit: https://github.com/vim/vim/commit/ab176ce982ac67f7cfcfa1fa885f9117ef8bbafe
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 15 21:19:08 2020 +0200
patch 8.2.0984: not using previous window when closing a shell popup window
Problem: Not using previous window when closing a shell popup window.
Solution: Use "prevwin" if it was set. (closes https://github.com/vim/vim/issues/6267)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 15 Jun 2020 21:30:04 +0200 |
parents | 186ff32aed7b |
children | c5d8fe261776 |
files | src/popupwin.c src/testdir/test_popupwin.vim src/version.c |
diffstat | 3 files changed, 35 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -2148,6 +2148,19 @@ invoke_popup_callback(win_T *wp, typval_ } /* + * 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,10 +2191,8 @@ popup_close_and_callback(win_T *wp, typv break; if (owp != NULL) win_enter(owp, FALSE); - else if (win_valid(prevwin) && wp != prevwin) - win_enter(prevwin, FALSE); else - win_enter(firstwin, FALSE); + back_to_prevwin(wp); } } #endif @@ -2583,7 +2594,7 @@ popup_close(int id, int force) error_for_popup_window(); return FAIL; } - win_enter(firstwin, FALSE); + back_to_prevwin(wp); } if (prev == NULL) first_popupwin = wp->w_next; @@ -2620,7 +2631,7 @@ popup_close_tabpage(tabpage_T *tp, int i error_for_popup_window(); return FAIL; } - win_enter(firstwin, FALSE); + back_to_prevwin(wp); } if (prev == NULL) *root = wp->w_next;
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -2461,6 +2461,23 @@ func Test_popupwin_terminal_buffer() 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))