Don't crash when no file is open on start
This commit is contained in:
parent
3c8edd4f0f
commit
2931f79d15
1 changed files with 13 additions and 4 deletions
|
|
@ -136,19 +136,28 @@ class DebugSession( object ):
|
|||
|
||||
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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue