Fix opening paths on Windows

This commit is contained in:
Ben Jackson 2020-01-03 00:19:47 +00:00
commit 4a7e3b9229
3 changed files with 22 additions and 7 deletions

View file

@ -201,9 +201,24 @@ def MakeSymlink( in_folder, link, pointing_to ):
RemoveIfExists( os.path.join( in_folder, link ) )
in_folder = os.path.abspath( in_folder )
pointing_to = os.path.relpath( os.path.abspath( pointing_to ),
in_folder )
os.symlink( pointing_to, os.path.join( in_folder, link ) )
pointing_to_relative = os.path.relpath( os.path.abspath( pointing_to ),
in_folder )
link_path = os.path.join( in_folder, link )
if install.GetOS() == 'windows':
# While symlinks do exist on Windows, they require elevated privileges, so
# let's use a directory junction which is all we need.
link_path = os.path.abspath( link_path )
if os.path.isdir( link_path ):
os.rmdir( link_path )
subprocess.check_call( [ 'cmd.exe',
'/c',
'mklink',
'/J',
link_path,
pointing_to ] )
else:
os.symlink( pointing_to_relative, link_path )
def CloneRepoTo( url, ref, destination ):

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from vimspector import utils,install
from vimspector import utils, install
import vim
import json

View file

@ -23,7 +23,7 @@ import string
import functools
LOG_FILE = os.path.expanduser( os.path.join( '~', '.vimspector.log') )
LOG_FILE = os.path.expanduser( os.path.join( '~', '.vimspector.log' ) )
_log_handler = logging.FileHandler( LOG_FILE, mode = 'w' )
@ -42,7 +42,7 @@ SetUpLogging( _logger )
def BufferNumberForFile( file_name ):
return int( vim.eval( 'bufnr( "{0}", 1 )'.format( file_name ) ) )
return int( vim.eval( "bufnr( '{0}', 1 )".format( Escape( file_name ) ) ) )
def BufferForFile( file_name ):
@ -52,7 +52,7 @@ def BufferForFile( file_name ):
def OpenFileInCurrentWindow( file_name ):
buffer_number = BufferNumberForFile( file_name )
try:
vim.command( 'bu {0}'.format( buffer_number ) )
vim.current.buffer = vim.buffers[ buffer_number ]
except vim.error as e:
if 'E325' not in str( e ):
raise