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 )
|
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 = {
|
self._variables = {
|
||||||
'dollar': '$', # HACK. Hote '$$' also works.
|
'dollar': '$', # HACK. Hote '$$' also works.
|
||||||
'workspaceRoot': self._workspace_root,
|
'workspaceRoot': self._workspace_root,
|
||||||
'workspaceFolder': self._workspace_root,
|
'workspaceFolder': self._workspace_root,
|
||||||
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ),
|
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ),
|
||||||
'file': current_file,
|
'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 ),
|
'fileBasename': os.path.basename( current_file ),
|
||||||
'fileBasenameNoExtension':
|
'fileBasenameNoExtension':
|
||||||
os.path.splitext( os.path.basename( current_file ) )[ 0 ],
|
splitext( os.path.basename( current_file ) )[ 0 ],
|
||||||
'fileDirname': os.path.dirname( current_file ),
|
'fileDirname': os.path.dirname( current_file ),
|
||||||
'fileExtname':
|
'fileExtname': splitext( os.path.basename( current_file ) )[ 1 ],
|
||||||
os.path.splitext( os.path.basename( current_file ) )[ 1 ],
|
|
||||||
'cwd': os.getcwd(),
|
'cwd': os.getcwd(),
|
||||||
}
|
}
|
||||||
self._variables.update(
|
self._variables.update(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue