Skip to content

Commit 131b182

Browse files
authored
Merge pull request #4252 from bstaletic/sig_help_wrap
Allow soft-wrapping of lines in the signature help window
2 parents f56c0cb + 05f688c commit 131b182

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

python/ycm/signature_help.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ def UpdateSignatureHelp( state, signature_info ): # noqa
159159
# inserting the char ?
160160
col = int( screen_pos[ 'curscol' ] ) - 2
161161

162+
# Vim stops shifting the popup to the left if we turn on soft-wrapping.
163+
# Instead, we want to first shift the popup to the left and then
164+
# and then turn on wrapping.
165+
max_line_length = max( len( item[ 'text' ] ) for item in buf_lines )
166+
vim_width = vimsupport.GetIntValue( '&columns' )
167+
line_available = vim_width - max( col, 1 )
168+
if max_line_length > line_available:
169+
col = vim_width - max_line_length
170+
162171
if col <= 0:
163172
col = 1
164173

@@ -172,6 +181,7 @@ def UpdateSignatureHelp( state, signature_info ): # noqa
172181
# cursorline. So instead, we manually set 'cursorline' in the popup window
173182
# and enable syntax based on the current file syntax)
174183
"flip": 1,
184+
"fixed": 1,
175185
"padding": [ 0, 1, 0, 1 ], # Pad 1 char in X axis to match completion menu
176186
"hidden": int( state.state == SignatureHelpState.ACTIVE_SUPPRESSED )
177187
}
@@ -196,7 +206,7 @@ def UpdateSignatureHelp( state, signature_info ): # noqa
196206

197207
active_signature = int( signature_info.get( 'activeSignature', 0 ) )
198208
vim.eval( f"win_execute( { state.popup_win_id }, "
199-
f"'set syntax={ syntax } cursorline | "
209+
f"'set syntax={ syntax } cursorline wrap | "
200210
f"call cursor( [ { active_signature + 1 }, 1 ] )' )" )
201211

202212
return state

0 commit comments

Comments
 (0)