Remove paired suffixes (#183)

* Remove paired suffixes

* Fix indentations

* This hack should work for double-quote or single-quote.
This commit is contained in:
mattn
2020-02-19 15:18:01 +09:00
committed by GitHub
parent c3b7078fd4
commit 312861e9f9

View File

@@ -442,6 +442,11 @@ function! s:recompute_pum(...) abort
endif
endfunction
let s:pair = {
\ '"': '"',
\ '''': '''',
\}
function! s:default_preprocessor(options, matches) abort
let l:items = []
let l:startcols = []
@@ -450,6 +455,14 @@ function! s:default_preprocessor(options, matches) abort
let l:base = a:options['typed'][l:startcol - 1:]
for l:item in l:matches['items']
if stridx(l:item['word'], l:base) == 0
" Strip pair characters. If pre-typed text is '"', candidates
" should have '"' suffix.
if has_key(s:pair, l:base[0])
let [l:lhs, l:rhs, l:str] = [l:base[0], s:pair[l:base[0]], l:item['word']]
if len(l:str) > 1 && l:str[0] ==# l:lhs && l:str[-1:] ==# l:rhs
let l:item['word'] = l:str[:-2]
endif
endif
let l:startcols += [l:startcol]
call add(l:items, l:item)
endif