Find the vimspector config from the parent of the open file not the current working directory
This commit is contained in:
parent
c4202958e8
commit
f173a043be
2 changed files with 14 additions and 6 deletions
|
|
@ -73,11 +73,15 @@ class DebugSession( object ):
|
||||||
self._configuration = None
|
self._configuration = None
|
||||||
self._adapter = None
|
self._adapter = None
|
||||||
|
|
||||||
launch_config_file = utils.PathToConfigFile( '.vimspector.json' )
|
current_file = utils.GetBufferFilepath( vim.current.buffer )
|
||||||
|
|
||||||
|
launch_config_file = utils.PathToConfigFile(
|
||||||
|
'.vimspector.json',
|
||||||
|
os.path.dirname( current_file ) )
|
||||||
|
|
||||||
if not launch_config_file:
|
if not launch_config_file:
|
||||||
utils.UserMessage( 'Unable to find .vimspector.json. You need to tell '
|
utils.UserMessage( 'Unable to find .vimspector.json. You need to tell '
|
||||||
'vimspector how to launch your application' )
|
'vimspector how to launch your application.' )
|
||||||
return
|
return
|
||||||
|
|
||||||
with open( launch_config_file, 'r' ) as f:
|
with open( launch_config_file, 'r' ) as f:
|
||||||
|
|
@ -134,8 +138,6 @@ class DebugSession( object ):
|
||||||
# ${selectedText} - the current selected text in the active file
|
# ${selectedText} - the current selected text in the active file
|
||||||
# ${execPath} - the path to the running VS Code executable
|
# ${execPath} - the path to the running VS Code executable
|
||||||
|
|
||||||
current_file = utils.GetBufferFilepath( vim.current.buffer )
|
|
||||||
|
|
||||||
def relpath( p, relative_to ):
|
def relpath( p, relative_to ):
|
||||||
if not p:
|
if not p:
|
||||||
return ''
|
return ''
|
||||||
|
|
@ -158,6 +160,8 @@ class DebugSession( object ):
|
||||||
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': splitext( os.path.basename( current_file ) )[ 1 ],
|
'fileExtname': splitext( os.path.basename( current_file ) )[ 1 ],
|
||||||
|
# NOTE: this is the window-local cwd for the current window, *not* Vim's
|
||||||
|
# working directory.
|
||||||
'cwd': os.getcwd(),
|
'cwd': os.getcwd(),
|
||||||
}
|
}
|
||||||
self._variables.update(
|
self._variables.update(
|
||||||
|
|
|
||||||
|
|
@ -207,8 +207,12 @@ def TemporaryVimOption( opt, value ):
|
||||||
vim.options[ opt ] = old_value
|
vim.options[ opt ] = old_value
|
||||||
|
|
||||||
|
|
||||||
def PathToConfigFile( file_name ):
|
def PathToConfigFile( file_name, from_directory = None ):
|
||||||
|
if not from_directory:
|
||||||
p = os.getcwd()
|
p = os.getcwd()
|
||||||
|
else:
|
||||||
|
p = os.path.abspath( os.path.realpath( from_directory ) )
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
candidate = os.path.join( p, file_name )
|
candidate = os.path.join( p, file_name )
|
||||||
if os.path.exists( candidate ):
|
if os.path.exists( candidate ):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue