forked from aniani/vim
patch 8.0.1223: crash when using autocomplete and tab pages
Problem: Crash when using autocomplete and tab pages. Solution: Check if the current tab changed. (Christian Brabandt, closes #2239)
This commit is contained in:
@@ -2313,7 +2313,8 @@ ins_char_bytes(char_u *buf, int charlen)
|
|||||||
|
|
||||||
/* Copy bytes after the changed character(s). */
|
/* Copy bytes after the changed character(s). */
|
||||||
p = newp + col;
|
p = newp + col;
|
||||||
mch_memmove(p + newlen, oldp + col + oldlen,
|
if (linelen > col + oldlen)
|
||||||
|
mch_memmove(p + newlen, oldp + col + oldlen,
|
||||||
(size_t)(linelen - col - oldlen));
|
(size_t)(linelen - col - oldlen));
|
||||||
|
|
||||||
/* Insert or overwrite the new character. */
|
/* Insert or overwrite the new character. */
|
||||||
|
@@ -566,6 +566,7 @@ pum_set_selected(int n, int repeat)
|
|||||||
&& vim_strchr(p_cot, 'p') != NULL)
|
&& vim_strchr(p_cot, 'p') != NULL)
|
||||||
{
|
{
|
||||||
win_T *curwin_save = curwin;
|
win_T *curwin_save = curwin;
|
||||||
|
tabpage_T *curtab_save = curtab;
|
||||||
int res = OK;
|
int res = OK;
|
||||||
|
|
||||||
/* Open a preview window. 3 lines by default. Prefer
|
/* Open a preview window. 3 lines by default. Prefer
|
||||||
@@ -653,8 +654,13 @@ pum_set_selected(int n, int repeat)
|
|||||||
curwin->w_cursor.lnum = 1;
|
curwin->w_cursor.lnum = 1;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
|
|
||||||
if (curwin != curwin_save && win_valid(curwin_save))
|
if ((curwin != curwin_save && win_valid(curwin_save))
|
||||||
|
|| (curtab != curtab_save
|
||||||
|
&& valid_tabpage(curtab_save)))
|
||||||
{
|
{
|
||||||
|
if (curtab != curtab_save && valid_tabpage(curtab_save))
|
||||||
|
goto_tabpage_tp(curtab_save, FALSE, FALSE);
|
||||||
|
|
||||||
/* When the first completion is done and the preview
|
/* When the first completion is done and the preview
|
||||||
* window is not resized, skip the preview window's
|
* window is not resized, skip the preview window's
|
||||||
* status line redrawing. */
|
* status line redrawing. */
|
||||||
|
@@ -661,4 +661,41 @@ func Test_popup_and_window_resize()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_popup_and_preview_autocommand()
|
||||||
|
" This used to crash Vim
|
||||||
|
if !has('python')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let h = winheight(0)
|
||||||
|
if h < 15
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
new
|
||||||
|
augroup MyBufAdd
|
||||||
|
au!
|
||||||
|
au BufAdd * nested tab sball
|
||||||
|
augroup END
|
||||||
|
set omnifunc=pythoncomplete#Complete
|
||||||
|
call setline(1, 'import os')
|
||||||
|
" make the line long
|
||||||
|
call setline(2, ' os.')
|
||||||
|
$
|
||||||
|
call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<C-N>\<enter>\<esc>", 'tx')
|
||||||
|
call assert_equal(["import os", " os.EX_IOERR", ''], getline(1,'$'))
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
" previewwindow option is not set
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
norm! gt
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
norm! gT
|
||||||
|
call assert_equal(12, tabpagenr('$'))
|
||||||
|
tabonly
|
||||||
|
pclose
|
||||||
|
augroup MyBufAdd
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! MyBufAdd
|
||||||
|
bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1223,
|
||||||
/**/
|
/**/
|
||||||
1222,
|
1222,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user