Use helper function to get current directory
Fix tests.
This commit is contained in:
parent
3109c9d8a4
commit
234658f30b
@ -33,7 +33,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from ycmd.utils import ToUnicode
|
||||
from ycmd.utils import GetCurrentDirectory, ToUnicode
|
||||
|
||||
|
||||
BUFNR_REGEX = re.compile( '^bufnr\(\'(?P<buffer_filename>.+)\', ([01])\)$' )
|
||||
@ -56,7 +56,7 @@ VIM_MOCK = MagicMock()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def CurrentWorkingDirectory( path ):
|
||||
old_cwd = os.getcwd()
|
||||
old_cwd = GetCurrentDirectory()
|
||||
os.chdir( path )
|
||||
try:
|
||||
yield
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Copyright (C) 2011, 2012 Google Inc.
|
||||
# Copyright (C) 2011-2012 Google Inc.
|
||||
# 2016 YouCompleteMe contributors
|
||||
#
|
||||
# This file is part of YouCompleteMe.
|
||||
#
|
||||
@ -26,11 +27,11 @@ from builtins import * # noqa
|
||||
from future.utils import iterkeys
|
||||
import vim
|
||||
import os
|
||||
import tempfile
|
||||
import json
|
||||
import re
|
||||
from collections import defaultdict
|
||||
from ycmd.utils import ToUnicode, ToBytes, JoinLinesAsUnicode
|
||||
from ycmd.utils import ( GetCurrentDirectory, JoinLinesAsUnicode, ToBytes,
|
||||
ToUnicode )
|
||||
from ycmd import user_options_store
|
||||
|
||||
BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit',
|
||||
@ -156,13 +157,8 @@ def GetBufferFilepath( buffer_object ):
|
||||
if buffer_object.name:
|
||||
return buffer_object.name
|
||||
# Buffers that have just been created by a command like :enew don't have any
|
||||
# buffer name so we use the buffer number for that. Also, os.getcwd() throws
|
||||
# an exception when the CWD has been deleted so we handle that.
|
||||
try:
|
||||
folder_path = os.getcwd()
|
||||
except OSError:
|
||||
folder_path = tempfile.gettempdir()
|
||||
return os.path.join( folder_path, str( buffer_object.number ) )
|
||||
# buffer name so we use the buffer number for that.
|
||||
return os.path.join( GetCurrentDirectory(), str( buffer_object.number ) )
|
||||
|
||||
|
||||
def UnplaceSignInBuffer( buffer_number, sign_id ):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Copyright (C) 2011, 2012 Google Inc.
|
||||
# Copyright (C) 2011-2012 Google Inc.
|
||||
# 2016 YouCompleteMe contributors
|
||||
#
|
||||
# This file is part of YouCompleteMe.
|
||||
#
|
||||
@ -225,7 +226,7 @@ class YouCompleteMe( object ):
|
||||
self._omnicomp, wrapped_request_data )
|
||||
return self._latest_completion_request
|
||||
|
||||
request_data[ 'working_dir' ] = os.getcwd()
|
||||
request_data[ 'working_dir' ] = utils.GetCurrentDirectory()
|
||||
|
||||
self._AddExtraConfDataIfNeeded( request_data )
|
||||
if force_semantic:
|
||||
@ -677,12 +678,8 @@ class YouCompleteMe( object ):
|
||||
def _AddTagsFilesIfNeeded( self, extra_data ):
|
||||
def GetTagFiles():
|
||||
tag_files = vim.eval( 'tagfiles()' )
|
||||
# getcwd() throws an exception when the CWD has been deleted.
|
||||
try:
|
||||
current_working_directory = os.getcwd()
|
||||
except OSError:
|
||||
return []
|
||||
return [ os.path.join( current_working_directory, x ) for x in tag_files ]
|
||||
return [ os.path.join( utils.GetCurrentDirectory(), tag_file )
|
||||
for tag_file in tag_files ]
|
||||
|
||||
if not self._user_options[ 'collect_identifiers_from_tags_files' ]:
|
||||
return
|
||||
|
2
third_party/ycmd
vendored
2
third_party/ycmd
vendored
@ -1 +1 @@
|
||||
Subproject commit f3232ce5180753822d839c80e9b9ea4e33e89d4c
|
||||
Subproject commit 63c3d992a2db8d189cd78a25a70c87348726fc52
|
Loading…
Reference in New Issue
Block a user