Skip to content

Preview popup unexpectedly closed when moving to next or previous quickfix item with 'n' or 'p' #7

@bfrg

Description

@bfrg

Sometimes the popup window is unexpectedly closed when moving to the next or previous quickfix item with the keys specified in with next and previous options.

It seems to be caused by vim-cool and occurs when n or N are pressed right before the preview popup is opened. It happens only with the following vim-qf-preview settings:

let g:qfpreview = {'previous': 'p', 'next': 'n'}

but not with, for example:

let g:qfpreview = {'previous': "\<c-p>", 'next': "\<c-n>"}

To reproduce

  1. Add the following settings to your vimrc:
    let g:qfpreview = {'previous': 'p', 'next': 'n'}
    
    augroup test
        autocmd!
        autocmd FileType qf nmap <Buffer> p <Plug>(qf-preview-open)
    augroup END
  2. Run vimgrep function $VIMRUNTIME/* or similar command to populate the quickfix list.
  3. Go to the quickfix window and press n or N to repeat the last / or ? pattern. It doesn't matter whether the next occurrence is found.
  4. Without moving the cursor press p to open the popup window.
  5. While the popup window is displayed move to the next or previous quickfix item with n or p, respectively.
  6. Result: vim-qf-preview moves the cursor properly to the next item but the popup window will close.
  7. Repeat step 3., but this time move the cursor with h/j/k/l before opening the popup window.
  8. Result: Moving to the next or previous quickfix item from the popup window works as expected.

Now use different keys for next and previous:

let g:qfpreview = {'previous': "\<c-p>", 'next': "\<c-n>"}

augroup test
    autocmd!
    autocmd FileType qf nmap <Buffer> p <Plug>(qf-preview-open)
augroup END

and repeat the above steps. Everything works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions