Skip to content

Commit

Permalink
Merge pull request #67 from puremourning/no-file
Browse files Browse the repository at this point in the history
Don't crash when no file is open on start
  • Loading branch information
mergify[bot] authored Nov 2, 2019
2 parents c26fe1d + 8ffc018 commit 64187ad
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,28 @@ def Start( self, launch_variables = {} ):

current_file = utils.GetBufferFilepath( vim.current.buffer )

def relpath( p, relative_to ):
if not p:
return ''
return os.path.relpath( p, relative_to )

def splitext( p ):
if not p:
return [ '', '' ]
return os.path.splitext( p )

self._variables = {
'dollar': '$', # HACK. Hote '$$' also works.
'workspaceRoot': self._workspace_root,
'workspaceFolder': self._workspace_root,
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ),
'file': current_file,
'relativeFile': os.path.relpath( current_file, self._workspace_root ),
'relativeFile': relpath( current_file, self._workspace_root ),
'fileBasename': os.path.basename( current_file ),
'fileBasenameNoExtension':
os.path.splitext( os.path.basename( current_file ) )[ 0 ],
splitext( os.path.basename( current_file ) )[ 0 ],
'fileDirname': os.path.dirname( current_file ),
'fileExtname':
os.path.splitext( os.path.basename( current_file ) )[ 1 ],
'fileExtname': splitext( os.path.basename( current_file ) )[ 1 ],
'cwd': os.getcwd(),
}
self._variables.update(
Expand Down

0 comments on commit 64187ad

Please sign in to comment.