Sorry for the delay; for some reason, I didn't get an email update for your 
response. A misconfiguration on my side.

You're right, I should have provided more detail. The original problem report 
(https://groups.google.com/forum/#!msg/vim_dev/k1Wo5Fv6e3E/CUjMnFEWlxYJ) 
provides more info, but that's no excuse for not going in-depth here.

I've encountered this problem with two different plugins; one of them is 
something I'm still working on, the other plugin is neocomplcache. The issue 
report for neo is here: 
https://github.com/Shougo/neocomplcache/issues/185#issuecomment-5527679 . That 
issue report has more details as well.

The problem is the following: let's say we have the following mapping in our 
vimrc:

" With this command, when the completion window is visible, the tab key will
" select the next candidate in the window. In vim, this also changes the
" typed-in text to that of the candidate completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"

completeopt has 'menuone' and 'preview'.

Let's say we also have a function tied to CursorMovedI that basically just 
calls feedkeys like this: 

" <c-x><c-u> invokes the user's completion function and <c-p> tells vim to 
select the previous
" completion candidate. This is necessary because by default, vim selects the
" first candidate when completion is invoked, and selecting a candidate
" automatically replaces the current text with it. Calling <c-p> forces vim to
" deselect the first candidate and in turn preserve the user's current text
" until he explicitly chooses to replace it with a completion with, say, the 
<TAB>
call feedkeys( "\<C-X>\<C-U>\<C-P>", 'n' )

This means that the custom completefunc is called on every keystroke in insert 
mode. Let's say that that completefunc always returns a dictionary with the 
'words' list containing one string ("example") and 'refresh' is set to 
'always'. It does this for every keystroke. (Of course, when findstart is set, 
it returns the location of the beginning of the typed-in word. Nothing special.)

Something like the following (this was quickly hacked together from multiple 
parts for the sake of example; I'm not saying it works):

fun! NewComplete(findstart, base)
  if a:findstart
    " locate the start of the word
    let line = getline('.')
    let start = col('.') - 1
    while start > 0 && line[start - 1] =~ '\a'
      let start -= 1
    endwhile
    return start
  else
    let l:results = ['example']
    let dict = { 'words' : results }
    let dict.refresh = 'always'
    return dict
  endif
endfun

This completefunc in combination with the feedkeys call ensures that no matter 
what the user types in insert mode, the completion window pops up with 
"example". This completion suggestion is not inserted automatically; it's only 
inserted if the user presses TAB. If the user  then:

1. Goes in insert mode.
2. Types in "example test" (ignoring the offered completions)
3. Leaves insert mode (now we're back in normal mode)
4. Presses '.'

... the user will then see gibberish inserted instead of "example test" again. 
Without refresh set to always, "example test" is inserted correctly.

This is what I mean when I say that the dot register breaks for refresh: always.

Of course, the plugins I'm referring to don't use such a simple completefunc; 
they in fact return new completion candidates on every keystroke, but I believe 
that's besides the point here.

On Monday, April 30, 2012 12:35:30 AM UTC-7, JohnBeckett wrote:
> Val Markovic wrote:
> > Any help, advice or guidance would be greatly appreciated.
> 
> Someone needs to spend quality time:
> 1. Working out the problem is.
> 2. Fixing problem.
> 
> You could help point 1 by giving a brief indication of what the
> problem is. Yes, the subject line tried to do that, but a few
> lines with a simple demo and a description (what does "break"
> mean?) may help.
> 
> John

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui