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

Function UpdateSignatureHelp

python/ycm/signature_help.py:89–212  ·  view source on GitHub ↗
( state, signature_info )

Source from the content-addressed store, hash-verified

87
88
89def UpdateSignatureHelp( state, signature_info ): # noqa
90 if not ShouldUseSignatureHelp():
91 return state
92
93 signatures = signature_info.get( 'signatures' ) or []
94
95 if not signatures:
96 if state.popup_win_id:
97 # TODO/FIXME: Should we use popup_hide() instead ?
98 vim.eval( f"popup_close( { state.popup_win_id } )" )
99 return SignatureHelpState( None, SignatureHelpState.INACTIVE )
100
101 if state.state == SignatureHelpState.INACTIVE:
102 state.anchor = vimsupport.CurrentLineAndColumn()
103
104 state.state = SignatureHelpState.ACTIVE
105
106 # Generate the buffer as a list of lines
107 buf_lines = _MakeSignatureHelpBuffer( signature_info )
108 screen_pos = vimsupport.ScreenPositionForLineColumnInWindow(
109 vim.current.window,
110 state.anchor[ 0 ] + 1, # anchor 0-based
111 state.anchor[ 1 ] + 1 ) # anchor 0-based
112
113 # Simulate 'flip' at the screen boundaries by using screenpos and hiding the
114 # signature help menu if it overlaps the completion popup (pum).
115 #
116 # FIXME: revert to cursor-relative positioning and the 'flip' option when that
117 # is implemented (if that is indeed better).
118
119 # By default display above the anchor
120 line = int( screen_pos[ 'row' ] ) - 1 # -1 to display above the cur line
121 pos = "botleft"
122
123 cursor_line = vimsupport.CurrentLineAndColumn()[ 0 ] + 1
124 if int( screen_pos[ 'row' ] ) <= len( buf_lines ):
125 # No room at the top, display below
126 line = int( screen_pos[ 'row' ] ) + 1
127 pos = "topleft"
128
129 # Don't allow the popup to overlap the cursor
130 if ( pos == 'topleft' and
131 line < cursor_line and
132 line + len( buf_lines ) >= cursor_line ):
133 line = 0
134
135 # Don't allow the popup to overlap the pum
136 if line > 0 and GetIntValue( 'pumvisible()' ):
137 pum_line = GetIntValue( 'pum_getpos().row' ) + 1
138 if pos == 'botleft' and pum_line <= line:
139 line = 0
140 elif ( pos == 'topleft' and
141 pum_line >= line and
142 pum_line < ( line + len( buf_lines ) ) ):
143 line = 0
144
145 if line <= 0:
146 # Nowhere to put it so hide it

Callers

nothing calls this directly

Calls 5

GetIntValueFunction · 0.90
ShouldUseSignatureHelpFunction · 0.85
SignatureHelpStateClass · 0.85
_MakeSignatureHelpBufferFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected