mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-19 20:38:05 +01:00
fixed bug with <c-r><tab> completion
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
" File: snipMate.vim
|
" File: snipMate.vim
|
||||||
" Author: Michael Sanders
|
" Author: Michael Sanders
|
||||||
" Version: 0.81
|
" Version: 0.82
|
||||||
" Description: snipMate.vim implements some of TextMate's snippets features in
|
" Description: snipMate.vim implements some of TextMate's snippets features in
|
||||||
" Vim. A snippet is a piece of often-typed text that you can
|
" Vim. A snippet is a piece of often-typed text that you can
|
||||||
" insert into your document using a trigger word followed by a "<tab>".
|
" insert into your document using a trigger word followed by a "<tab>".
|
||||||
@@ -69,7 +69,7 @@ fun! ExtractSnipsFile(file, ft)
|
|||||||
let text = readfile(a:file)
|
let text = readfile(a:file)
|
||||||
let inSnip = 0
|
let inSnip = 0
|
||||||
for line in text + ["\n"]
|
for line in text + ["\n"]
|
||||||
if inSnip && (line == '' || strpart(line, 0, 1) == "\t")
|
if inSnip && (line[0] == "\t" || line == '')
|
||||||
let content .= strpart(line, 1)."\n"
|
let content .= strpart(line, 1)."\n"
|
||||||
continue
|
continue
|
||||||
elseif inSnip
|
elseif inSnip
|
||||||
@@ -189,17 +189,19 @@ fun s:ChooseSnippet(scope, trigger)
|
|||||||
return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
|
return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun ShowAvailableSnips()
|
fun! ShowAvailableSnips()
|
||||||
let word = matchstr(getline('.'), '\S\+\%'.col('.').'c')
|
let line = getline('.')
|
||||||
|
let col = col('.')
|
||||||
|
let word = matchstr(getline('.'), '\S\+\%'.col.'c')
|
||||||
let words = [word]
|
let words = [word]
|
||||||
if stridx(word, '.')
|
if stridx(word, '.')
|
||||||
let words += split(word, '\.', 1)
|
let words += split(word, '\.', 1)
|
||||||
endif
|
endif
|
||||||
let matchpos = 0
|
let matchlen = 0
|
||||||
let matches = []
|
let matches = []
|
||||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||||
let triggers = exists('s:snippets["'.scope.'"]') ? keys(s:snippets[scope]) : []
|
let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : []
|
||||||
if exists('s:multi_snips["'.scope.'"]')
|
if has_key(s:multi_snips, scope)
|
||||||
let triggers += keys(s:multi_snips[scope])
|
let triggers += keys(s:multi_snips[scope])
|
||||||
endif
|
endif
|
||||||
for trigger in triggers
|
for trigger in triggers
|
||||||
@@ -209,12 +211,16 @@ fun ShowAvailableSnips()
|
|||||||
elseif trigger =~ '^'.word
|
elseif trigger =~ '^'.word
|
||||||
let matches += [trigger]
|
let matches += [trigger]
|
||||||
let len = len(word)
|
let len = len(word)
|
||||||
if len > matchpos | let matchpos = len | endif
|
if len > matchlen | let matchlen = len | endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
call complete(col('.') - matchpos, matches)
|
|
||||||
|
" This is to avoid a bug with Vim when using complete(col - matchlen, matches)
|
||||||
|
" (Issue#46 on the Google Code snipMate issue tracker).
|
||||||
|
call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', ''))
|
||||||
|
call complete(col, matches)
|
||||||
return ''
|
return ''
|
||||||
endf
|
endf
|
||||||
" vim:noet:sw=4:ts=4:ft=vim
|
" vim:noet:sw=4:ts=4:ft=vim
|
||||||
|
|||||||
Reference in New Issue
Block a user