Commits

Takeshi NISHIDA  committed e81fe2c

minor fix for auto preview

  • Participants
  • Parent commits e646c99

Comments (0)

Files changed (1)

File autoload/fuf.vim

         \   [ g:fuf_keyOpenTabpage   , 'onCr(' . s:OPEN_TYPE_TAB     . ', 0)' ],
         \   [ '<BS>'                 , 'onBs()'                               ],
         \   [ '<C-h>'                , 'onBs()'                               ],
-        \   [ g:fuf_keyPreview       , 'onPreviewBase()'                      ],
+        \   [ g:fuf_keyPreview       , 'onPreviewBase(1)'                     ],
         \   [ g:fuf_keyNextMode      , 'onSwitchMode(+1)'                     ],
         \   [ g:fuf_keyPrevMode      , 'onSwitchMode(-1)'                     ],
         \   [ g:fuf_keySwitchMatching, 'onSwitchMatching()'                   ],
         \ 's:setRanks(v:val, patternSet.primaryForRank, exprBoundary, stats)')
 endfunction
 
+          "\ 'inoremap <buffer> <silent> %s <C-r>=fuf#getRunningHandler().%s ? "" : ""<CR>',
 "
 function s:handlerBase.onComplete(findstart, base)
   if a:findstart
     call s:highlightError()
   else
     call sort(items, 'fuf#compareRanks')
-    call feedkeys("\<C-p>\<Down>", 'n')
     if g:fuf_autoPreview
-      call feedkeys("\<C-@>", 'm')
+      call feedkeys("\<C-p>\<Down>\<C-r>=fuf#getRunningHandler().onPreviewBase(0) ? '' : ''\<CR>", 'n')
+    else
+      call feedkeys("\<C-p>\<Down>", 'n')
     endif
     let self.lastFirstWord = items[0].word
   endif
 endfunction
 
 "
-function s:handlerBase.onPreviewBase()
+function s:handlerBase.onPreviewBase(repeatable)
   if self.getPreviewHeight() <= 0
     return
   elseif !pumvisible()
     let word = self.lastFirstWord
   endif
   redraw
-  if exists('self.lastPreviewInfo') && self.lastPreviewInfo.word ==# word
+  if a:repeatable && exists('self.lastPreviewInfo') && self.lastPreviewInfo.word ==# word
     let self.lastPreviewInfo.count += 1
   else
     let self.lastPreviewInfo = {'word': word, 'count': 0}