Patch 8.1.2076
Problem: Crash when trying to put a terminal buffer in a popup window.
Solution: Check for NULL buffer. Do not allow putting a terminal in a popup
window.
Files: src/libvterm/src/termscreen.c, src/terminal.c, src/popupwin.c,
runtime/doc/popup.txt, src/testdir/test_popupwin.vim
*** ../vim-8.1.2075/src/libvterm/src/termscreen.c 2019-09-13 22:30:07.588524105 +0200
--- src/libvterm/src/termscreen.c 2019-09-25 21:54:58.080071987 +0200
***************
*** 75,80 ****
--- 75,82 ----
return NULL;
if(col < 0 || col >= screen->cols)
return NULL;
+ if (screen->buffer == NULL)
+ return NULL;
return screen->buffer + (screen->cols * row) + col;
}
*** ../vim-8.1.2075/src/terminal.c 2019-09-21 23:09:00.979830687 +0200
--- src/terminal.c 2019-09-25 22:01:54.602118518 +0200
***************
*** 3347,3352 ****
--- 3347,3354 ----
newcols = MIN(newcols, twp->w_width);
}
}
+ if (newrows == 99999 || newcols == 99999)
+ return; // safety exit
newrows = rows == 0 ? newrows : minsize ? MAX(rows, newrows) : rows;
newcols = cols == 0 ? newcols : minsize ? MAX(cols, newcols) : cols;
*** ../vim-8.1.2075/src/popupwin.c 2019-09-14 22:23:26.334003207 +0200
--- src/popupwin.c 2019-09-25 22:07:15.716571033 +0200
***************
*** 1638,1643 ****
--- 1638,1648 ----
semsg(_(e_nobufnr), argvars[0].vval.v_number);
return NULL;
}
+ if (buf->b_term != NULL)
+ {
+ emsg(_("E278: Cannot put a terminal buffer in a popup window"));
+ return NULL;
+ }
}
else if (!(argvars[0].v_type == VAR_STRING
&& argvars[0].vval.v_string != NULL)
*** ../vim-8.1.2075/runtime/doc/popup.txt 2019-09-04 18:15:16.174573730 +0200
--- runtime/doc/popup.txt 2019-09-25 22:09:03.320058743 +0200
***************
*** 137,145 ****
call setwinvar(winid, '&wrap', 0)
And options can be set on the buffer with `setbufvar()`, e.g.: >
call setbufvar(winbufnr(winid), '&filetype', 'java')
! Note that this does not trigger autocommands. Use `win_execute()` if you do
! need them.
!
==============================================================================
--- 137,143 ----
call setwinvar(winid, '&wrap', 0)
And options can be set on the buffer with `setbufvar()`, e.g.: >
call setbufvar(winbufnr(winid), '&filetype', 'java')
! You can also use `win_execute()` with a ":setlocal" command.
==============================================================================
***************
*** 204,210 ****
\ mousemoved: 'WORD',
\ })
< Use {options} to change the properties.
! See |popup_beval_example| for an example use.
Can also be used as a |method|: >
GetText()->popup_beval({})
--- 202,208 ----
\ mousemoved: 'WORD',
\ })
< Use {options} to change the properties.
! See |popup_beval_example| for an example.
Can also be used as a |method|: >
GetText()->popup_beval({})
***************
*** 540,545 ****
--- 538,547 ----
dictionary with a "col" entry, see below:
|popup-props|.
+ If you want to create a new buffer yourself use |bufadd()| and pass the buffer
+ number to popup_create().
+ It is not possible to use the buffer of a terminal window. *E278*
+
The second argument of |popup_create()| is a dictionary with options:
line Screen line where to position the popup. Can use a
number or "cursor", "cursor+1" or "cursor-1" to use
*** ../vim-8.1.2075/src/testdir/test_popupwin.vim 2019-09-21 22:56:59.484287781 +0200
--- src/testdir/test_popupwin.vim 2019-09-25 22:11:57.683233140 +0200
***************
*** 1992,1997 ****
--- 1992,2003 ----
call delete('XsomeFile')
endfunc
+ func Test_popupwin_terminal_buffer()
+ let ptybuf = term_start(&shell, #{hidden: 1})
+ call assert_fails('let winnr = popup_create(ptybuf, #{})', 'E278:')
+ exe 'bwipe! ' .. ptybuf
+ endfunc
+
func Test_popupwin_with_buffer_and_filter()
new Xwithfilter
call setline(1, range(100))
*** ../vim-8.1.2075/src/version.c 2019-09-25 21:43:07.275251603 +0200
--- src/version.c 2019-09-25 21:55:51.867827050 +0200
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 2076,
/**/
--
A real patriot is the fellow who gets a parking ticket and rejoices
that the system works.
/// Bram Moolenaar -- Br...@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 ///