fix(vim): match prefix when handling completion

This commit is contained in:
arielherself 2024-12-28 17:09:00 +08:00
parent 356d01933d
commit cf903619ea
Signed by: arielherself
SSH Key Fingerprint: SHA256:AK3cyo9tFsp7Mox7K0sYphleC8hReXhnRKxwuDT5LBc
1 changed files with 7 additions and 3 deletions

10
.vimrc
View File

@ -142,11 +142,15 @@ endfunction
function! s:truncate_labels(options, matches) abort
let l:items = []
for [l:source_name, l:matches] in items(a:matches)
let l:startcol = l:matches['startcol']
let l:base = a:options['typed'][l:startcol - 1:]
for l:item in l:matches['items']
if has_key(l:item, 'abbr')
let l:item['abbr'] = s:truncate(l:item['abbr'])
if stridx(l:item['word'], l:base) == 0
if has_key(l:item, 'abbr')
let l:item['abbr'] = s:truncate(l:item['abbr'])
endif
call add(l:items, l:item)
endif
call add(l:items, l:item)
endfor
endfor