Merge pull request #268 from puremourning/breakpoints-file-while-debugging

While debugging, use the correct path for breakpoints
This commit is contained in:
mergify[bot] 2020-09-27 22:12:33 +00:00 committed by GitHub
commit 692a0d8d39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 203 additions and 8 deletions

View file

@ -268,7 +268,10 @@ class ProjectBreakpoints( object ):
awaiting = awaiting + 1
self._connection.DoRequest(
lambda msg: response_handler( source, msg ),
# The source=source here is critical to ensure that we capture each
# source in the iteration, rather than ending up passing the same source
# to each callback.
lambda msg, source=source: response_handler( source, msg ),
{
'command': 'setBreakpoints',
'arguments': {

View file

@ -119,7 +119,6 @@ class CodeView( object ):
return False
self._current_frame = frame
self._DisplayPC()
if not self._window.valid:
return False
@ -148,6 +147,8 @@ class CodeView( object ):
self.current_syntax = utils.ToUnicode(
vim.current.buffer.options[ 'syntax' ] )
self.ShowBreakpoints()
return True
def Clear( self ):

View file

@ -0,0 +1,21 @@
{
"configurations": {
"run": {
"adapter": "debugpy",
"default": true,
"configuration": {
"request": "launch",
"program": "${workspaceRoot}/moo.py",
"cwd": "${workspaceRoot}",
"stopOnEntry": true
},
"breakpoints": {
"exception": {
"raised": "N",
"uncaught": "",
"userUnhandled": ""
}
}
}
}
}

View file

@ -0,0 +1,15 @@
def Say( *args, **kwargs ):
print( *args, **kwargs )
def Quiet():
pass

View file

@ -0,0 +1,13 @@
import cow
def Moo():
for i in range( 1, 100 ):
cow.Say( 'Moo' )
for i in range( 1, 100 ):
cow.Say( 'Ooom' )
if __name__ == '__main__':
Moo()

View file

@ -576,7 +576,7 @@ function! Test_Custom_Breakpoint_Priority()
\ 'vimspectorBPDisabled',
\ 4 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 16 )
call setpos( '.', [ 0, 17, 1 ] )
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
@ -663,7 +663,7 @@ function! Test_Custom_Breakpoint_Priority_Partial()
\ 'vimspectorBPDisabled',
\ 4 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 16 )
call setpos( '.', [ 0, 17, 1 ] )
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
@ -723,3 +723,72 @@ function! Test_Custom_Breakpoint_Priority_Partial()
%bwipeout!
unlet! g:vimspector_sign_priority
endfunction
function! Test_Add_Line_BP_In_Other_File_While_Debugging()
let moo = 'moo.py'
let cow = 'cow.py'
lcd ../support/test/python/multiple_files
exe 'edit' moo
call vimspector#Launch()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( moo, 1, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( moo, 1 )
call cursor( 6, 3 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertPCIsAtLineInBuffer( moo, 1 )
call WaitForAssert( {->
\vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorCode',
\ 6,
\ 'vimspectorBP',
\ 9 ) } )
exe 'edit' cow
call cursor( 2, 1 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', 6 )
call WaitForAssert( {->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorCode',
\ 2,
\ 'vimspectorBP',
\ 9 ) } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( moo, 6, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( moo, 6 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', 2 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 6,
\ 'vimspectorBP',
\ 9 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 6,
\ 'vimspectorPCBP',
\ 200 )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( cow, 2, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( cow, 2 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', 6 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 2,
\ 'vimspectorBP',
\ 9 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 2,
\ 'vimspectorPCBP',
\ 200 )
lcd -
call vimspector#test#setup#Reset()
%bwipe!
endfunction

View file

@ -577,7 +577,7 @@ function! Test_Custom_Breakpoint_Priority()
\ 'vimspectorBPDisabled',
\ 4 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 16 )
call setpos( '.', [ 0, 17, 1 ] )
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
@ -664,7 +664,7 @@ function! Test_Custom_Breakpoint_Priority_Partial()
\ 'vimspectorBPDisabled',
\ 4 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 16 )
call setpos( '.', [ 0, 17, 1 ] )
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
@ -724,3 +724,72 @@ function! Test_Custom_Breakpoint_Priority_Partial()
%bwipeout!
unlet! g:vimspector_sign_priority
endfunction
function! Test_Add_Line_BP_In_Other_File_While_Debugging()
let moo = 'moo.py'
let cow = 'cow.py'
lcd ../support/test/python/multiple_files
exe 'edit' moo
call vimspector#Launch()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( moo, 1, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( moo, 1 )
call cursor( 6, 3 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertPCIsAtLineInBuffer( moo, 1 )
call WaitForAssert( {->
\vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorCode',
\ 6,
\ 'vimspectorBP',
\ 9 ) } )
exe 'edit' cow
call cursor( 2, 1 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', 6 )
call WaitForAssert( {->
\ vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorCode',
\ 2,
\ 'vimspectorBP',
\ 9 ) } )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( moo, 6, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( moo, 6 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', 2 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 6,
\ 'vimspectorBP',
\ 9 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 6,
\ 'vimspectorPCBP',
\ 200 )
call vimspector#Continue()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( cow, 2, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( cow, 2 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorCode', 6 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 2,
\ 'vimspectorBP',
\ 9 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 2,
\ 'vimspectorPCBP',
\ 200 )
lcd -
call vimspector#test#setup#Reset()
%bwipe!
endfunction

View file

@ -70,7 +70,11 @@ function! vimspector#test#signs#AssertSignGroupSingletonAtLine( group,
endfunction
function! vimspector#test#signs#AssertSignAtLine( group, line, sign_name, priority ) abort
function! vimspector#test#signs#AssertSignAtLine(
\ group,
\ line,
\ sign_name,
\ priority ) abort
let signs = sign_getplaced( '%', {
\ 'group': a:group,
@ -106,7 +110,7 @@ endfunction
function! vimspector#test#signs#AssertSignGroupEmptyAtLine( group, line ) abort
let signs = sign_getplaced( '%', {
\ 'group': a:group,
\ 'lnum': line( '.' )
\ 'lnum': a:line,
\ } )
return assert_equal( 1,