GoTo commands now work when spaces in filenames

Fixes #977
This commit is contained in:
Strahinja Val Markovic 2014-05-19 12:37:30 -07:00
parent 68f3577b87
commit ec6966236c

View File

@ -247,6 +247,10 @@ def BufferIsUsable( buffer_object ):
return not BufferModified( buffer_object ) or HiddenEnabled( buffer_object ) return not BufferModified( buffer_object ) or HiddenEnabled( buffer_object )
def EscapedFilepath( filepath ):
return filepath.replace( ' ' , r'\ ' )
# Both |line| and |column| need to be 1-based # Both |line| and |column| need to be 1-based
def JumpToLocation( filename, line, column ): def JumpToLocation( filename, line, column ):
# Add an entry to the jumplist # Add an entry to the jumplist
@ -263,7 +267,8 @@ def JumpToLocation( filename, line, column ):
command = BUFFER_COMMAND_MAP.get( user_command, 'edit' ) command = BUFFER_COMMAND_MAP.get( user_command, 'edit' )
if command == 'edit' and not BufferIsUsable( vim.current.buffer ): if command == 'edit' and not BufferIsUsable( vim.current.buffer ):
command = 'split' command = 'split'
vim.command( 'keepjumps {0} {1}'.format( command, filename ) ) vim.command( 'keepjumps {0} {1}'.format( command,
EscapedFilepath( filename ) ) )
vim.current.window.cursor = ( line, column - 1 ) vim.current.window.cursor = ( line, column - 1 )
# Center the screen on the jumped-to location # Center the screen on the jumped-to location