Skip to content

Commit

Permalink
fix longest highlight to use <up>/<down> + to work properly w/ longes…
Browse files Browse the repository at this point in the history
…t enhanced
  • Loading branch information
ervandew committed Mar 9, 2011
1 parent edfcc1d commit e026beb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugin/supertab.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" Original: Gergely Kontra <kgergely@mcl.hu>
" Current: Eric Van Dewoestine <ervandew@gmail.com> (as of version 0.4)
" Please direct all correspondence to Eric.
" Version: 1.5
" Version: 1.6
" GetLatestVimScripts: 1643 1 :AutoInstall: supertab.vim
"
" Description: {{{
Expand Down Expand Up @@ -325,12 +325,6 @@ function! s:SuperTab(command)
call s:EnableLongestEnhancement()
endif

" highlight first result if longest enabled
if g:SuperTabLongestHighlight && !pumvisible() && &completeopt =~ 'longest'
let key = (b:complType == "\<c-p>") ? b:complType : "\<c-n>"
call feedkeys(key)
endif

if !pumvisible()
let b:complTypeManual = ''
endif
Expand Down Expand Up @@ -386,6 +380,14 @@ function! s:SuperTab(command)
let complType = b:complType
endif

" highlight first result if longest enabled
if g:SuperTabLongestHighlight &&
\ &completeopt =~ 'longest' &&
\ (!pumvisible() || b:complReset)
let key = (complType == "\<c-p>") ? "\<up>" : "\<down>"
call feedkeys(key, 'n')
endif

if b:complReset
let b:complReset = 0
" not an accurate condition for everyone, but better than sending <c-e>
Expand Down

3 comments on commit e026beb

@blueyed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to cause problems with g:SuperTabLongestHighlight=1 and only a single entry in the completion list: then entry is automatically picked, and then the cursor moves one line upwards.

I've thrown a "echomsg pumvisible()" in there (above) and it says "0" always, even when the menu comes up (for non-exact matches).

Looking at ":h 'completeopt'" you may have to handle also "menuone" here.

@ervandew
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to cause problems with g:SuperTabLongestHighlight=1 and only a single entry in the completion list: then entry is automatically picked, and then the cursor moves one line upwards.

Hmm, I can't reproduce this. Can you open an issue (http://github.com/ervandew/supertab/issues) and include your completeopt value (:set completeopt?) along with an example of how to reproduce the problem (the file's text, the text prior to attempting completion, the completion method you're using, etc.).

@blueyed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created issue #14 about this.

Please sign in to comment.