vim-jp/vim-cpp

Cursor jumping after calling ccomplete#Complete()

lifepillar opened this issue · 1 comments

Source this code:

fun! Collect(word)
  call   ccomplete#Complete(1, '')
  return ccomplete#Complete(0, a:word)
endf

fun! MyComplete(word, col)
  " let l:wv = winsaveview()
  let l:suggestions = Collect(a:word)
  " call winrestview(l:wv)
  if !empty(l:suggestions)
    call complete(col('.') - len(a:word), l:suggestions)
  endif
  return ''
endf

Then create a new cpp buffer, and type the following text:

for for1

for1

With the cursor at the end of the buffer (after the second for1), type <c-r>=MyComplete('for1',0). The pop-up menu will open below the first line. If the window view is saved and restored (see the commented lines above), the bug does not occur.

According to :h E839:

The function is allowed to move the cursor, it is restored afterwards.

but it seems that the cursor is not restored.

mattn commented

This repository is for syntax/c.vim or syntax/cpp.vim. not manged completion things. please send your issue into vim's issues.

https://github.com/vim/vim/issues/new