Fix insertion adjustment for omnifunc candidates

The abbr field may not be present for candidates returned by Vim's
omnifunc.
This commit is contained in:
micbou 2018-12-11 02:15:24 +01:00
parent 80246aa9a2
commit 6b8349ba8e
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05
2 changed files with 8 additions and 1 deletions

View File

@ -103,7 +103,7 @@ def AdjustCandidateInsertionText( candidates ):
for candidate in candidates: for candidate in candidates:
new_candidate = candidate.copy() new_candidate = candidate.copy()
if not new_candidate[ 'abbr' ]: if not new_candidate.get( 'abbr' ):
new_candidate[ 'abbr' ] = new_candidate[ 'word' ] new_candidate[ 'abbr' ] = new_candidate[ 'word' ]
new_candidate[ 'word' ] = NewCandidateInsertionText( new_candidate[ 'word' ] = NewCandidateInsertionText(

View File

@ -130,6 +130,13 @@ def AdjustCandidateInsertionText_DontTouchAbbr_test():
{ 'word': 'foobar', 'abbr': '1234' } ] ) ) { 'word': 'foobar', 'abbr': '1234' } ] ) )
def AdjustCandidateInsertionText_NoAbbr_test():
with MockTextAfterCursor( 'bar' ):
eq_( [ { 'word': 'foo', 'abbr': 'foobar' } ],
base.AdjustCandidateInsertionText( [
{ 'word': 'foobar' } ] ) )
def OverlapLength_Basic_test(): def OverlapLength_Basic_test():
eq_( 3, base.OverlapLength( 'foo bar', 'bar zoo' ) ) eq_( 3, base.OverlapLength( 'foo bar', 'bar zoo' ) )
eq_( 3, base.OverlapLength( 'foobar', 'barzoo' ) ) eq_( 3, base.OverlapLength( 'foobar', 'barzoo' ) )