|
@@ -139,10 +139,10 @@ def GetUnsavedAndSpecifiedBufferData( including_filepath ):
|
|
|
return buffers_data
|
|
|
|
|
|
|
|
|
-def GetBufferNumberForFilename( filename, open_file_if_needed = True ):
|
|
|
+def GetBufferNumberForFilename( filename, create_buffer_if_needed = False ):
|
|
|
return GetIntValue( u"bufnr('{0}', {1})".format(
|
|
|
EscapeForVim( os.path.realpath( filename ) ),
|
|
|
- int( open_file_if_needed ) ) )
|
|
|
+ int( create_buffer_if_needed ) ) )
|
|
|
|
|
|
|
|
|
def GetCurrentBufferFilepath():
|
|
@@ -328,7 +328,8 @@ def ConvertDiagnosticsToQfList( diagnostics ):
|
|
|
text += ' (FixIt available)'
|
|
|
|
|
|
return {
|
|
|
- 'bufnr' : GetBufferNumberForFilename( location[ 'filepath' ] ),
|
|
|
+ 'bufnr' : GetBufferNumberForFilename( location[ 'filepath' ],
|
|
|
+ create_buffer_if_needed = True ),
|
|
|
'lnum' : line_num,
|
|
|
'col' : location[ 'column_num' ],
|
|
|
'text' : text,
|
|
@@ -641,7 +642,7 @@ def _GetNumNonVisibleFiles( file_list ):
|
|
|
are not curerntly open in visible windows"""
|
|
|
return len(
|
|
|
[ f for f in file_list
|
|
|
- if not BufferIsVisible( GetBufferNumberForFilename( f, False ) ) ] )
|
|
|
+ if not BufferIsVisible( GetBufferNumberForFilename( f ) ) ] )
|
|
|
|
|
|
|
|
|
def _OpenFileInSplitIfNeeded( filepath ):
|
|
@@ -658,7 +659,7 @@ def _OpenFileInSplitIfNeeded( filepath ):
|
|
|
not to open a file, or if opening fails, this method raises RuntimeError,
|
|
|
otherwise, guarantees to return a visible buffer number in buffer_num."""
|
|
|
|
|
|
- buffer_num = GetBufferNumberForFilename( filepath, False )
|
|
|
+ buffer_num = GetBufferNumberForFilename( filepath )
|
|
|
|
|
|
# We only apply changes in the current tab page (i.e. "visible" windows).
|
|
|
# Applying changes in tabs does not lead to a better user experience, as the
|
|
@@ -681,7 +682,7 @@ def _OpenFileInSplitIfNeeded( filepath ):
|
|
|
# OpenFilename returns us to the original cursor location. This is what we
|
|
|
# want, because we don't want to disorientate the user, but we do need to
|
|
|
# know the (now open) buffer number for the filename
|
|
|
- buffer_num = GetBufferNumberForFilename( filepath, False )
|
|
|
+ buffer_num = GetBufferNumberForFilename( filepath )
|
|
|
if not BufferIsVisible( buffer_num ):
|
|
|
# This happens, for example, if there is a swap file and the user
|
|
|
# selects the "Quit" or "Abort" options. We just raise an exception to
|
|
@@ -959,16 +960,16 @@ def WriteToPreviewWindow( message ):
|
|
|
|
|
|
def BufferIsVisibleForFilename( filename ):
|
|
|
"""Check if a buffer exists for a specific file."""
|
|
|
- buffer_number = GetBufferNumberForFilename( filename, False )
|
|
|
+ buffer_number = GetBufferNumberForFilename( filename )
|
|
|
return BufferIsVisible( buffer_number )
|
|
|
|
|
|
|
|
|
def CloseBuffersForFilename( filename ):
|
|
|
"""Close all buffers for a specific file."""
|
|
|
- buffer_number = GetBufferNumberForFilename( filename, False )
|
|
|
+ buffer_number = GetBufferNumberForFilename( filename )
|
|
|
while buffer_number != -1:
|
|
|
vim.command( 'silent! bwipeout! {0}'.format( buffer_number ) )
|
|
|
- new_buffer_number = GetBufferNumberForFilename( filename, False )
|
|
|
+ new_buffer_number = GetBufferNumberForFilename( filename )
|
|
|
if buffer_number == new_buffer_number:
|
|
|
raise RuntimeError( "Buffer {0} for filename '{1}' should already be "
|
|
|
"wiped out.".format( buffer_number, filename ) )
|