/CoreOS/vim/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim /CoreOS/vim/Regression/bz1204179-missing-bin-vi-breaks-visudo-sudoedit-crontab /CoreOS/vim/Regression/bz1383902-CPU-spike-on-ssh /CoreOS/vim/Regression/bz1490927-vim-dumps-core-when-system-reboots /CoreOS/vim/Regression/bz1576470-Suggest-correct-packages-to-get-embedded /CoreOS/vim/Regression/bz1602807-vim-X11-doesn-t-provide-the-gui /CoreOS/vim/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace /CoreOS/vim/Regression/bz1686822-Add-Provides-bundled-libvterm /CoreOS/vim/Regression/bz1743070-manpage-of-vim-is-garbled-in-Japanese-locale /CoreOS/vim/Regression/bz241308-use-augroup-for-rh-autocmds /CoreOS/vim/Regression/bz429208-maxmemtot-memory-calculation /CoreOS/vim/Regression/bz473977-vim-incorrectly-linked-to-libtermcap /CoreOS/vim/Regression/bz505344-netrw-plugin-delete-command-broken /CoreOS/vim/Regression/bz506442-Add-Vim-to-Applications-Accessories-menu /CoreOS/vim/Regression/bz572157-vim-in-ex-mode-incorrectly-gives-an-eol-error /CoreOS/vim/Regression/bz591578-netrw-vim-prints-additional-chars /CoreOS/vim/Regression/bz634902-rpm-spec-template-is-out-of-date /CoreOS/vim/Regression/bz652610-netrw-plugin-and-parent-directory /CoreOS/vim/Regression/bz681108-vim-crashes-while-doing-completion /CoreOS/vim/Regression/bz820331-Vim-syntax-file-for-sshdconfig-is-missing-newer /CoreOS/vim/Regression/docs /CoreOS/vim/Sanity/upstream-scripttests
84 lines
2.7 KiB
VimL
84 lines
2.7 KiB
VimL
" Test case by Ingo Karkat:
|
|
" http://vim.1045645.n5.nabble.com/Crash-with-completefunc-mapping-followed-by-text-td1210506.html
|
|
"
|
|
|
|
function! s:FindMatchesInCurrentWindow( matches, pattern, matchTemplate, options, isInCompletionBuffer )
|
|
let l:isBackward = has_key(a:options, 'backward_search')
|
|
|
|
let l:save_cursor = getpos('.')
|
|
|
|
let l:firstMatchPos = [0,0]
|
|
while ! complete_check()
|
|
let l:matchPos = searchpos( a:pattern, 'w' . (l:isBackward ? 'b' : '') )
|
|
if l:matchPos == [0,0] || l:matchPos == l:firstMatchPos
|
|
break
|
|
endif
|
|
if l:firstMatchPos == [0,0]
|
|
let l:firstMatchPos = l:matchPos
|
|
endif
|
|
|
|
let l:matchEndPos = searchpos( a:pattern, 'cen' )
|
|
if a:isInCompletionBuffer && (l:matchEndPos == l:save_cursor[1:2])
|
|
continue
|
|
endif
|
|
|
|
let l:matchObj = copy(a:matchTemplate)
|
|
let l:matchText = a:options.extractor(l:matchPos, l:matchEndPos, l:matchObj)
|
|
|
|
let l:matchObj.word = l:matchText
|
|
|
|
if ! empty(l:matchText) && index(a:matches, l:matchObj) == -1
|
|
call add( a:matches, l:matchObj )
|
|
endif
|
|
endwhile
|
|
|
|
call setpos('.', l:save_cursor)
|
|
endfunction
|
|
|
|
function! MotionComplete_ExtractText( startPos, endPos, matchObj )
|
|
let l:save_cursor = getpos('.')
|
|
let @@ = ''
|
|
call setpos('.', [0, a:startPos[0], a:startPos[1], 0])
|
|
execute 'silent! normal y' . s:motion
|
|
let l:text = @@
|
|
call setpos('.', l:save_cursor)
|
|
return l:text
|
|
endfunction
|
|
|
|
function! s:LocateStartCol()
|
|
let l:startCol = searchpos('\k\+\%(\k\@!.\)*\%#', 'bn', line('.'))[1]
|
|
if l:startCol == 0
|
|
let l:startCol = col('.')
|
|
endif
|
|
return l:startCol
|
|
endfunction
|
|
|
|
function! s:MotionComplete( findstart, base )
|
|
if a:findstart
|
|
return s:LocateStartCol() - 1 " Return byte index, not column.
|
|
else
|
|
let l:options = {}
|
|
let l:options.extractor = function('MotionComplete_ExtractText')
|
|
let l:matches = []
|
|
call s:FindMatchesInCurrentWindow( l:matches, '\V\<' . escape(a:base, '\'), {}, l:options, 1 )
|
|
return l:matches
|
|
endif
|
|
endfunction
|
|
|
|
let s:motion = 'w'
|
|
|
|
inoremap <silent> <Plug>MotionComplete <C-o>:set completefunc=<SID>MotionComplete<CR><C-x><C-u>
|
|
|
|
" The original mapping that caused the crash.
|
|
" In combination with an expression to select the first match in the popup menu
|
|
" (this is useful in combination with :set completeopt=menu,longest), Vim
|
|
" crashes.
|
|
"imap <F12> <Plug>MotionComplete<C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>
|
|
|
|
" A simplified mapping that still causes the crash.
|
|
imap <F12> <Plug>MotionComplete+Some-More-Text
|
|
|
|
" The bare mapping works fine.
|
|
if exists('nobug')
|
|
imap <F12> <Plug>MotionComplete
|
|
endif
|