Ensure signs are only padded when 1 display cell

This commit is contained in:
Ben Jackson 2020-08-23 12:52:03 +01:00
commit dae5760900
3 changed files with 22 additions and 4 deletions

View file

@ -53,13 +53,19 @@ class ProjectBreakpoints( object ):
self._next_sign_id = 1
if not utils.SignDefined( 'vimspectorBP' ):
vim.command( 'sign define vimspectorBP text=\\ ● texthl=WarningMsg' )
utils.DefineSign( 'vimspectorBP',
text = '',
texthl = 'WarningMsg' )
if not utils.SignDefined( 'vimspectorBPCond' ):
vim.command( 'sign define vimspectorBPCond text=\\ ◆ texthl=WarningMsg' )
utils.DefineSign( 'vimspectorBPCond',
text = '',
texthl = 'WarningMsg' )
if not utils.SignDefined( 'vimspectorBPDisabled' ):
vim.command( 'sign define vimspectorBPDisabled text=\\ ● texthl=LineNr' )
utils.DefineSign( 'vimspectorBPDisabled',
text = '',
texthl = 'LineNr' )
def ConnectionUp( self, connection ):

View file

@ -51,7 +51,9 @@ class CodeView( object ):
vim.command( 'nnoremenu WinBar.✕ :call vimspector#Reset()<CR>' )
if not utils.SignDefined( 'vimspectorPC' ):
vim.command( 'sign define vimspectorPC text=\\ ▶ texthl=MatchParen' )
utils.DefineSign( 'vimspectorPC',
text = '',
texthl = 'MatchParen' )
def SetCurrentFrame( self, frame ):

View file

@ -777,3 +777,13 @@ def WindowID( window, tab=None ):
if tab is None:
tab = window.tabpage
return int( Call( 'win_getid', window.number, tab.number ) )
def DefineSign( name, text, texthl, col = 'right' ):
if col == 'right':
if int( Call( 'strdisplaywidth', text ) ) < 2:
text = ' ' + text
text = text.replace( ' ', r'\ ' )
vim.command( f'sign define { name } text={ text } texthl={ texthl }' )