Fix popup-on-dot completion: use <C-p> to deselect the first entry

Without this, the <C-x><C-o> triggered by jedi-vim would cause the first
match to be inserted (and selected).  When using completopt=longest,
this was less so an issue.
This commit is contained in:
Daniel Hahler
2015-04-26 03:39:28 +02:00
parent cc254432b6
commit 63dc0badac

View File

@@ -240,16 +240,23 @@ function! jedi#complete_string(is_popup_on_dot)
if pumvisible() && !a:is_popup_on_dot if pumvisible() && !a:is_popup_on_dot
return "\<C-n>" return "\<C-n>"
else else
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened()\<CR>" return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:is_popup_on_dot.")\<CR>"
endif endif
endfunction endfunction
function! jedi#complete_opened() function! jedi#complete_opened(is_popup_on_dot)
if pumvisible() && g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1 if pumvisible()
" only go down if it is visible, user-enabled and the longest option is set if a:is_popup_on_dot
" Prevent completion of the first entry with dot completion.
return "\<C-p>"
endif
" Only go down if it is visible, user-enabled and the longest
" option is set.
if g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
return "\<Down>" return "\<Down>"
endif endif
endif
return "" return ""
endfunction endfunction