Fix duplicate entries in filename completion

We could just remove the "dup: 1" part in the completion dict, but that would
leave the duplicate removal up to Vim which would be slow. Also, we might not
end up returning the correct number of results then.
This commit is contained in:
Strahinja Val Markovic 2013-07-08 15:56:54 -07:00
parent ac5b5bfdbe
commit a011eb6aa0

View File

@ -125,10 +125,18 @@ def GetPathsStandardCase( path_dir ):
def GenerateCandidatesForPaths( absolute_paths ): def GenerateCandidatesForPaths( absolute_paths ):
def GenerateCandidateForPath( absolute_path ): seen_basenames = set()
is_dir = os.path.isdir( absolute_path ) completion_dicts = []
return { 'word': os.path.basename( absolute_path ),
'dup': 1,
'menu': '[Dir]' if is_dir else '[File]' }
return [ GenerateCandidateForPath( path ) for path in absolute_paths ] for absolute_path in absolute_paths:
basename = os.path.basename( absolute_path )
if basename in seen_basenames:
continue
seen_basenames.add( basename )
is_dir = os.path.isdir( absolute_path )
completion_dicts.append( { 'word': basename,
'dup': 1,
'menu': '[Dir]' if is_dir else '[File]' } )
return completion_dicts