From cf903619ea61de4a1a7d2f43cf09ca172eefc1cb Mon Sep 17 00:00:00 2001 From: arielherself Date: Sat, 28 Dec 2024 17:09:00 +0800 Subject: [PATCH] fix(vim): match prefix when handling completion --- .vimrc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.vimrc b/.vimrc index f3720c4..42e4c96 100644 --- a/.vimrc +++ b/.vimrc @@ -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