Feature: Silent Errors if not connected

This commit is contained in:
tinmarino 2020-01-15 10:28:50 -03:00
commit 9be0f43a5f
2 changed files with 31 additions and 8 deletions

View file

@ -228,16 +228,21 @@ def Escape( msg ):
return msg.replace( "'", "''" )
def UserMessage( msg, persist=False ):
def UserMessage( msg, persist=False, error=False):
if persist:
_logger.warning( 'User Msg: ' + msg )
else:
_logger.info( 'User Msg: ' + msg )
vim.command( 'redraw' )
cmd = 'echom' if persist else 'echo'
for line in msg.split( '\n' ):
vim.command( "{0} '{1}'".format( cmd, Escape( line ) ) )
vim.command( 'redraw' )
try:
if error:
vim.command("echohl WarningMsg")
for line in msg.split( '\n' ):
vim.command( "{0} '{1}'".format( cmd, Escape( line ) ) )
finally:
vim.command('echohl None') if error else None
vim.command( 'redraw' )