]> granicus.if.org Git - vim/commitdiff
patch 8.2.0286: cannot use popup_close() for a terminal popup v8.2.0286
authorBram Moolenaar <Bram@vim.org>
Thu, 20 Feb 2020 19:12:29 +0000 (20:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 20 Feb 2020 19:12:29 +0000 (20:12 +0100)
Problem:    Cannot use popup_close() for a terminal popup.
Solution:   Allow using popup_close(). (closes #5666)

runtime/doc/popup.txt
src/popupwin.c
src/testdir/dumps/Test_terminal_popup_5.dump [new file with mode: 0644]
src/testdir/dumps/Test_terminal_popup_6.dump [new file with mode: 0644]
src/testdir/test_terminal.vim
src/version.c

index 55565bc86012ab0c36f26c091cc4652af66f1339..5122994137c0293d27b2374a1a0b69b8febc0e1b 100644 (file)
@@ -1,4 +1,4 @@
-*popup.txt*  For Vim version 8.2.  Last change: 2020 Feb 05
+*popup.txt*  For Vim version 8.2.  Last change: 2020 Feb 20
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -148,6 +148,8 @@ different:                                          *E863*
 - The popup window always has focus, it is not possible to switch to another
   window.
 - When the job ends, the popup window closes.
+- The popup window can be closed with `popup_close()`, the terminal buffer
+  then becomes hidden.
 - The default Pmenu color is only used for the border and padding.  To change
   the color of the terminal itself set 'wincolor'.
 
index 56d04b57e9c26dba30092c9ade73fff77605a9cb..407837850d750f0bf0fa45e0bd4f6e0206760cfb 100644 (file)
@@ -2360,7 +2360,12 @@ f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
     int                id = (int)tv_get_number(argvars);
     win_T      *wp;
 
-    if (ERROR_IF_ANY_POPUP_WINDOW)
+    if (
+# ifdef FEAT_TERMINAL
+       // if the popup contains a terminal it will become hidden
+       curbuf->b_term == NULL &&
+# endif
+           ERROR_IF_ANY_POPUP_WINDOW)
        return;
 
     wp = find_popup_win(id);
diff --git a/src/testdir/dumps/Test_terminal_popup_5.dump b/src/testdir/dumps/Test_terminal_popup_5.dump
new file mode 100644 (file)
index 0000000..7dbf1a6
--- /dev/null
@@ -0,0 +1,15 @@
+>0+0&#ffffff0| @73
+|1| @73
+|2| @73
+|3| @73
+|4| @73
+|5| @73
+|6| @73
+|7| @73
+|8| @73
+|9| @73
+|1|0| @72
+|1@1| @72
+|1|2| @72
+|1|3| @72
+|:|c|a|l@1| |C|l|o|s|e|P|o|p|u|p|(|)| @38|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_terminal_popup_6.dump b/src/testdir/dumps/Test_terminal_popup_6.dump
new file mode 100644 (file)
index 0000000..ebc6770
--- /dev/null
@@ -0,0 +1,15 @@
+|0+0&#ffffff0| @73
+|1| @73
+|2| @73
+|3| @12|╔+0#0000001#ffd7ff255|═@44|╗| +0#0000000#ffffff0@13
+|4| @12|║+0#0000001#ffd7ff255|s+0#0000000#ffffff0|o|m|e| |t|e|x|t| @35|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|5| @12|║+0#0000001#ffd7ff255|t+0#0000000#ffffff0|o| >e+0&#ffff4012|d|i|t| +0&#ffffff0@37|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|6| @12|║+0#0000001#ffd7ff255|i+0#0000000#ffffff0|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @27|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|7| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|8| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|9| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|1|0| @11|║+0#0000001#ffd7ff255|/+0#0000000#ffffff0|e|d|i|t| @21|2|,|4| @10|A|l@1| |║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
+|1@1| @11|╚+0#0000001#ffd7ff255|═@44|╝| +0#0000000#ffffff0@13
+|1|2| @72
+|1|3| @72
+@57|1|,|1| @10|A|l@1| 
index e0761c4bdfbef47585fa7806229638347c699d28..64bc7db1ed157f62cf702c616a0094b3881af909 100644 (file)
@@ -2337,8 +2337,8 @@ func Test_terminal_in_popup()
        \ 'call setline(1, range(20))',
        \ 'hi PopTerm ctermbg=grey',
        \ 'func OpenTerm(setColor)',
-       \ "  let buf = term_start('" .. cmd .. " Xtext', #{hidden: 1, term_finish: 'close'})",
-       \ '  let s:winid = popup_create(buf, #{minwidth: 45, minheight: 7, border: [], drag: 1, resize: 1})',
+       \ "  let s:buf = term_start('" .. cmd .. " Xtext', #{hidden: 1, term_finish: 'close'})",
+       \ '  let s:winid = popup_create(s:buf, #{minwidth: 45, minheight: 7, border: [], drag: 1, resize: 1})',
        \ '  if a:setColor',
        \ '    call win_execute(s:winid, "set wincolor=PopTerm")',
        \ '  endif',
@@ -2347,6 +2347,12 @@ func Test_terminal_in_popup()
        \ 'func HidePopup()',
        \ '  call popup_hide(s:winid)',
        \ 'endfunc',
+       \ 'func ClosePopup()',
+       \ '  call popup_close(s:winid)',
+       \ 'endfunc',
+       \ 'func ReopenPopup()',
+       \ '  call popup_create(s:buf, #{minwidth: 40, minheight: 6, border: []})',
+       \ 'endfunc',
        \ 'sleep 10m',
        \ 'redraw',
        \ 'echo getwinvar(s:winid, "&buftype") win_gettype(s:winid)',
@@ -2370,6 +2376,13 @@ func Test_terminal_in_popup()
   call term_sendkeys(buf, "\<CR>")
   call term_wait(buf, 100)
 
+  call term_sendkeys(buf, "\<C-W>:call ClosePopup()\<CR>")
+  call VerifyScreenDump(buf, 'Test_terminal_popup_5', {})
+
+  call term_sendkeys(buf, "\<C-W>:call ReopenPopup()\<CR>")
+  call VerifyScreenDump(buf, 'Test_terminal_popup_6', {})
+  call term_wait(buf, 100)
+
   call term_sendkeys(buf, ":q\<CR>")
   call term_wait(buf, 100)  " wait for terminal to vanish
 
index 9dc3c6fa9ddfc8f300a9cfc943d4049895b274aa..e17c98b23207235dcfe787648a373cfd264c6a40 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    286,
 /**/
     285,
 /**/