Use CursorLine highlihgt to highlight current PC line

This commit is contained in:
Ben Jackson 2020-09-01 16:30:16 +01:00
commit dffd65f241
5 changed files with 97 additions and 6 deletions

View file

@ -1370,7 +1370,7 @@ define them in your `vimrc`.
| `vimspectorBP` | Line breakpoint | 9 |
| `vimspectorBPCond` | Conditional line breakpiont | 9 |
| `vimspectorBPDisabled` | Disabled breakpoint | 9 |
| `vimspectorPC` | Program counter (i.e. current line) | 20 |
| `vimspectorPC` | Program counter (i.e. current line) | 200 |
The default symbols are the equivalent of something like the following:
@ -1378,7 +1378,7 @@ The default symbols are the equivalent of something like the following:
sign define vimspectorBP text=\ ● texthl=WarningMsg
sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg
sign define vimspectorBPDisabled text=\ ● texthl=LineNr
sign define vimspectorPC text=\ ▶ texthl=MatchParen
sign define vimspectorPC text=\ ▶ texthl=MatchParen linehl=CursorLine
```
If the signs don't display properly, your font probably doesn't contain these

View file

@ -53,7 +53,8 @@ class CodeView( object ):
if not signs.SignDefined( 'vimspectorPC' ):
signs.DefineSign( 'vimspectorPC',
text = '',
texthl = 'MatchParen' )
texthl = 'MatchParen',
linehl = 'CursorLine' )
def SetCurrentFrame( self, frame ):

View file

@ -28,7 +28,7 @@ DEFAULTS = {
# Signs
'sign_priority': {
'vimspectorPC': 20,
'vimspectorPC': 200,
'vimspectorBP': 9,
'vimspectorBPCond': 9,
'vimspectorBPDisabled': 9,

View file

@ -12,14 +12,18 @@ def SignDefined( name ):
return False
def DefineSign( name, text, texthl, col = 'right' ):
def DefineSign( name, text, texthl, col = 'right', **kwargs ):
if col == 'right':
if int( utils.Call( 'strdisplaywidth', text ) ) < 2:
text = ' ' + text
text = text.replace( ' ', r'\ ' )
vim.command( f'sign define { name } text={ text } texthl={ texthl }' )
cmd = f'sign define { name } text={ text } texthl={ texthl }'
for key, value in kwargs.items():
cmd += f' { key }={ value }'
vim.command( cmd )
def PlaceSign( sign_id, group, name, file, line ):

View file

@ -633,6 +633,92 @@ function! Test_Custom_Breakpoint_Priority()
%bwipeout!
endfunction
function! Test_Custom_Breakpoint_Priority_Partial()
let g:vimspector_sign_priority = {
\ 'vimspectorBP': 2,
\ 'vimspectorBPCond': 3,
\ 'vimspectorBPDisabled': 4
\ }
" While not debugging
lcd testdata/cpp/simple
edit simple.cpp
call setpos( '.', [ 0, 15, 1 ] )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
\ 15,
\ 'vimspectorBP',
\ 2 )
call setpos( '.', [ 0, 16, 1 ] )
call vimspector#ToggleBreakpoint()
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorBP',
\ 16,
\ 'vimspectorBPDisabled',
\ 4 )
call vimspector#ToggleBreakpoint()
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 15 )
call setpos( '.', [ 0, 17, 1 ] )
call vimspector#ToggleBreakpoint( { 'condition': '1' } )
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorBP',
\ 17,
\ 'vimspectorBPCond',
\ 3 )
" While debugging
call vimspector#Launch()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 15, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 15 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 15,
\ 'vimspectorBP',
\ 2 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 15,
\ 'vimspectorPC',
\ 200 )
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorCode',
\ 17,
\ 'vimspectorBP',
\ 2 )
call vimspector#StepOver()
" No sign as disabled
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 16, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 16 )
call vimspector#StepOver()
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( 'simple.cpp', 17, 1 )
call vimspector#test#signs#AssertPCIsAtLineInBuffer( 'simple.cpp', 17 )
call vimspector#test#signs#AssertSignGroupSingletonAtLine(
\ 'VimspectorCode',
\ 15,
\ 'vimspectorBP',
\ 2 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 17,
\ 'vimspectorBP',
\ 2 )
call vimspector#test#signs#AssertSignAtLine(
\ 'VimspectorCode',
\ 17,
\ 'vimspectorPC',
\ 200 )
call vimspector#test#setup#Reset()
lcd -
%bwipeout!
endfunction
function! TearDown_Test_Custom_Breakpoint_Priority()
unlet! g:vimspector_sign_priority
endfunction