From 82661d515b08eb1506addfe7a1b378de946a9e27 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 7 Aug 2017 20:34:10 +0200 Subject: [PATCH] Fix restoring alternate terminal with completeopt redirection Fixes https://github.com/davidhalter/jedi-vim/issues/721. --- plugin/jedi.vim | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 6fe1bcc..485cdb7 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -16,11 +16,28 @@ if get(g:, 'jedi#auto_vim_configuration', 1) filetype plugin on " Change completeopt, but only if it was not set already. - redir => completeopt - silent verb set completeopt? - redir END - if len(split(completeopt, '\n')) == 1 - set completeopt=menuone,longest,preview + " This gets done on VimEnter, since otherwise Vim fails to restore the + " screen. Neovim is not affected, this is likely caused by using + " :redir/execute() before the (alternate) terminal is configured. + function! s:setup_completeopt() + if exists('*execute') + let completeopt = execute('silent verb set completeopt?') + else + redir => completeopt + silent verb set completeopt? + redir END + endif + if len(split(completeopt, '\n')) == 1 + set completeopt=menuone,longest,preview + endif + endfunction + if has('nvim') + call s:setup_completeopt() + else + augroup jedi_startup + au! + autocmd VimEnter * call s:setup_completeopt() + augroup END endif if len(mapcheck('', 'i')) == 0