MCPcopy
hub / github.com/ycm-core/YouCompleteMe / PostVimMessage

Function PostVimMessage

python/ycm/vimsupport.py:725–764  ·  view source on GitHub ↗

Display a message on the Vim status line. By default, the message is highlighted and logged to Vim command-line history (see :h history). Unset the |warning| parameter to disable this behavior. Set the |truncate| parameter to avoid hit-enter prompts (see :h hit-enter) when the message is lon

( message, warning = True, truncate = False )

Source from the content-addressed store, hash-verified

723# the time of writing, YCM only uses the GUI thread inside Vim (this used to
724# not be the case).
725def PostVimMessage( message, warning = True, truncate = False ):
726 """Display a message on the Vim status line. By default, the message is
727 highlighted and logged to Vim command-line history (see :h history).
728 Unset the |warning| parameter to disable this behavior. Set the |truncate|
729 parameter to avoid hit-enter prompts (see :h hit-enter) when the message is
730 longer than the window width."""
731 echo_command = 'echom' if warning else 'echo'
732
733 # Displaying a new message while previous ones are still on the status line
734 # might lead to a hit-enter prompt or the message appearing without a
735 # newline so we do a redraw first.
736 vim.command( 'redraw' )
737
738 if warning:
739 vim.command( 'echohl WarningMsg' )
740
741 message = ToUnicode( message )
742
743 if truncate:
744 vim_width = GetIntValue( '&columns' )
745
746 message = message.replace( '\n', ' ' )
747 message = message.replace( '\t', ' ' )
748 if len( message ) >= vim_width:
749 message = message[ : vim_width - 4 ] + '...'
750
751 old_ruler = GetIntValue( '&ruler' )
752 old_showcmd = GetIntValue( '&showcmd' )
753 vim.command( 'set noruler noshowcmd' )
754
755 vim.command( f"{ echo_command } '{ EscapeForVim( message ) }'" )
756
757 SetVariableValue( '&ruler', old_ruler )
758 SetVariableValue( '&showcmd', old_showcmd )
759 else:
760 for line in message.split( '\n' ):
761 vim.command( f"{ echo_command } '{ EscapeForVim( line ) }'" )
762
763 if warning:
764 vim.command( 'echohl None' )
765
766
767def PresentDialog( message, choices, default_choice_index = 0 ):

Callers 4

_HandlePollResponseFunction · 0.90
ReplaceChunksFunction · 0.85
InsertNamespaceFunction · 0.85
WriteToPreviewWindowFunction · 0.85

Calls 3

GetIntValueFunction · 0.85
EscapeForVimFunction · 0.85
SetVariableValueFunction · 0.85

Tested by

no test coverage detected