File&Dir issue fix
This commit is contained in:
parent
bd6f7d8dfb
commit
619e1c0b83
@ -24,6 +24,8 @@ from ycm.completers.cpp.clang_completer import InCFamilyFile
|
|||||||
from ycm.completers.cpp.flags import Flags
|
from ycm.completers.cpp.flags import Flags
|
||||||
from ycm.server import responses
|
from ycm.server import responses
|
||||||
|
|
||||||
|
EXTRA_INFO_MAP = { 1 : '[File]', 2 : '[Dir]', 3 : '[File&Dir]' }
|
||||||
|
|
||||||
class FilenameCompleter( Completer ):
|
class FilenameCompleter( Completer ):
|
||||||
"""
|
"""
|
||||||
General completer that provides filename and filepath completions.
|
General completer that provides filename and filepath completions.
|
||||||
@ -136,18 +138,16 @@ def _GetPathsStandardCase( path_dir, use_working_dir, filepath ):
|
|||||||
|
|
||||||
|
|
||||||
def _GenerateCandidatesForPaths( absolute_paths ):
|
def _GenerateCandidatesForPaths( absolute_paths ):
|
||||||
seen_basenames = set()
|
extra_info = dict()
|
||||||
completion_dicts = []
|
|
||||||
|
|
||||||
for absolute_path in absolute_paths:
|
for absolute_path in absolute_paths:
|
||||||
basename = os.path.basename( absolute_path )
|
basename = os.path.basename( absolute_path )
|
||||||
if basename in seen_basenames:
|
|
||||||
continue
|
|
||||||
seen_basenames.add( basename )
|
|
||||||
|
|
||||||
is_dir = os.path.isdir( absolute_path )
|
is_dir = os.path.isdir( absolute_path )
|
||||||
|
extra_info[ basename ] = extra_info.get( basename, 0 ) | \
|
||||||
|
( 2 if is_dir else 1 )
|
||||||
|
|
||||||
|
completion_dicts = []
|
||||||
|
for basename, value in extra_info.iteritems():
|
||||||
completion_dicts.append(
|
completion_dicts.append(
|
||||||
responses.BuildCompletionData( basename,
|
responses.BuildCompletionData( basename, EXTRA_INFO_MAP[ value ] ) )
|
||||||
'[Dir]' if is_dir else '[File]' ) )
|
|
||||||
|
|
||||||
return completion_dicts
|
return completion_dicts
|
||||||
|
Loading…
Reference in New Issue
Block a user