Including current file dir for #include "" form

Relevant to issue #273
This commit is contained in:
Strahinja Val Markovic 2013-04-25 12:56:32 -07:00
parent f4615c00c0
commit a9215f10fe

View File

@ -78,8 +78,11 @@ class FilenameCompleter( ThreadedCompleter ):
include_match = self._include_regex.search( line ) include_match = self._include_regex.search( line )
if include_match: if include_match:
path_dir = line[ include_match.end(): ] path_dir = line[ include_match.end(): ]
# We do what GCC does for <> versus "":
# http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
include_current_file_dir = '<' not in include_match.group()
return GenerateCandidatesForPaths( return GenerateCandidatesForPaths(
self.GetPathsIncludeCase( path_dir ) ) self.GetPathsIncludeCase( path_dir, include_current_file_dir ) )
path_match = self._path_regex.search( line ) path_match = self._path_regex.search( line )
path_dir = os.path.expanduser( path_match.group() ) if path_match else '' path_dir = os.path.expanduser( path_match.group() ) if path_match else ''
@ -87,10 +90,13 @@ class FilenameCompleter( ThreadedCompleter ):
return GenerateCandidatesForPaths( GetPathsStandardCase( path_dir ) ) return GenerateCandidatesForPaths( GetPathsStandardCase( path_dir ) )
def GetPathsIncludeCase( self, path_dir ): def GetPathsIncludeCase( self, path_dir, include_current_file_dir ):
paths = [] paths = []
include_paths = self._flags.UserIncludePaths( vim.current.buffer.name ) include_paths = self._flags.UserIncludePaths( vim.current.buffer.name )
if include_current_file_dir:
include_paths.append( os.path.dirname( vim.current.buffer.name ) )
for include_path in include_paths: for include_path in include_paths:
try: try:
relative_paths = os.listdir( os.path.join( include_path, path_dir ) ) relative_paths = os.listdir( os.path.join( include_path, path_dir ) )