diff --git a/python/ycm/client/base_request.py b/python/ycm/client/base_request.py index f04eca6085..2e35241bd9 100644 --- a/python/ycm/client/base_request.py +++ b/python/ycm/client/base_request.py @@ -249,16 +249,15 @@ def BuildRequestData( buffer_number = None ): } -def BuildRequestDataForLocation( location ): - file, line, column = location - if file not in vim.buffers: - vim.command( f'badd { file }' ) +def BuildRequestDataForLocation( file : str, line : int, columnt : int ): + buffer_number = vimsupport.GetBufferNumberForFilename( + file, + create_buffer_if_needed = True ) try: vim.eval( f'bufload( "{ file }" )' ) except vim.error as e: if 'E325' not in str( e ): raise - buffer_number = vimsupport.GetBufferNumberForFilename( file ) buffer = vim.buffers[ buffer_number ] file_data = vimsupport.GetUnsavedAndSpecifiedBufferData( buffer, file ) return { diff --git a/python/ycm/client/command_request.py b/python/ycm/client/command_request.py index 8216bf727c..a9045686d8 100644 --- a/python/ycm/client/command_request.py +++ b/python/ycm/client/command_request.py @@ -49,7 +49,7 @@ def __init__( self, def Start( self ): if self._location is not None: - self._request_data = BuildRequestDataForLocation( self._location ) + self._request_data = BuildRequestDataForLocation( *self._location ) elif self._bufnr is not None: self._request_data = BuildRequestData( self._bufnr ) else: