mirror of
https://github.com/prabirshrestha/asyncomplete.vim.git
synced 2025-12-14 20:35:41 +01:00
Remove paired suffixes (#183)
* Remove paired suffixes * Fix indentations * This hack should work for double-quote or single-quote.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user