diff --git a/python/ycm/base.py b/python/ycm/base.py index 1fb73dba..ee3c99b3 100644 --- a/python/ycm/base.py +++ b/python/ycm/base.py @@ -111,22 +111,16 @@ def AdjustCandidateInsertionText( candidates ): new_candidates = [] for candidate in candidates: - if isinstance( candidate, dict ): - new_candidate = candidate.copy() + new_candidate = candidate.copy() - if 'abbr' not in new_candidate: - new_candidate[ 'abbr' ] = new_candidate[ 'word' ] + if 'abbr' not in new_candidate: + new_candidate[ 'abbr' ] = new_candidate[ 'word' ] - new_candidate[ 'word' ] = NewCandidateInsertionText( - new_candidate[ 'word' ], - text_after_cursor ) + new_candidate[ 'word' ] = NewCandidateInsertionText( + new_candidate[ 'word' ], + text_after_cursor ) - new_candidates.append( new_candidate ) - - elif isinstance( candidate, str ) or isinstance( candidate, bytes ): - new_candidates.append( - { 'abbr': candidate, - 'word': NewCandidateInsertionText( candidate, text_after_cursor ) } ) + new_candidates.append( new_candidate ) return new_candidates diff --git a/python/ycm/tests/base_test.py b/python/ycm/tests/base_test.py index 9f7516d1..a7249b61 100644 --- a/python/ycm/tests/base_test.py +++ b/python/ycm/tests/base_test.py @@ -57,49 +57,49 @@ def MockTextAfterCursor( text ): def AdjustCandidateInsertionText_Basic_test(): with MockTextAfterCursor( 'bar' ): eq_( [ { 'abbr': 'foobar', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( [ 'foobar' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar' } ] ) ) def AdjustCandidateInsertionText_ParenInTextAfterCursor_test(): with MockTextAfterCursor( 'bar(zoo' ): eq_( [ { 'abbr': 'foobar', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( [ 'foobar' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar' } ] ) ) def AdjustCandidateInsertionText_PlusInTextAfterCursor_test(): with MockTextAfterCursor( 'bar+zoo' ): eq_( [ { 'abbr': 'foobar', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( [ 'foobar' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar' } ] ) ) def AdjustCandidateInsertionText_WhitespaceInTextAfterCursor_test(): with MockTextAfterCursor( 'bar zoo' ): eq_( [ { 'abbr': 'foobar', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( [ 'foobar' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar' } ] ) ) def AdjustCandidateInsertionText_MoreThanWordMatchingAfterCursor_test(): with MockTextAfterCursor( 'bar.h' ): eq_( [ { 'abbr': 'foobar.h', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( [ 'foobar.h' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar.h' } ] ) ) with MockTextAfterCursor( 'bar(zoo' ): eq_( [ { 'abbr': 'foobar(zoo', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( [ 'foobar(zoo' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar(zoo' } ] ) ) def AdjustCandidateInsertionText_NotSuffix_test(): with MockTextAfterCursor( 'bar' ): eq_( [ { 'abbr': 'foofoo', 'word': 'foofoo' } ], - base.AdjustCandidateInsertionText( [ 'foofoo' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foofoo' } ] ) ) def AdjustCandidateInsertionText_NothingAfterCursor_test(): with MockTextAfterCursor( '' ): - eq_( [ 'foofoo', - 'zobar' ], - base.AdjustCandidateInsertionText( [ 'foofoo', - 'zobar' ] ) ) + eq_( [ { 'word': 'foofoo' }, + { 'word': 'zobar' } ], + base.AdjustCandidateInsertionText( [ { 'word': 'foofoo' }, + { 'word': 'zobar' } ] ) ) def AdjustCandidateInsertionText_MultipleStrings_test(): @@ -108,17 +108,16 @@ def AdjustCandidateInsertionText_MultipleStrings_test(): { 'abbr': 'zobar', 'word': 'zo' }, { 'abbr': 'qbar', 'word': 'q' }, { 'abbr': 'bar', 'word': '' }, ], - base.AdjustCandidateInsertionText( [ 'foobar', - 'zobar', - 'qbar', - 'bar' ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar' }, + { 'word': 'zobar' }, + { 'word': 'qbar' }, + { 'word': 'bar' } ] ) ) def AdjustCandidateInsertionText_DictInput_test(): with MockTextAfterCursor( 'bar' ): eq_( [ { 'abbr': 'foobar', 'word': 'foo' } ], - base.AdjustCandidateInsertionText( - [ { 'word': 'foobar' } ] ) ) + base.AdjustCandidateInsertionText( [ { 'word': 'foobar' } ] ) ) def AdjustCandidateInsertionText_DontTouchAbbr_test():