Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow soft-wrapping of lines in the signature help window #4252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion python/ycm/signature_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@
# inserting the char ?
col = int( screen_pos[ 'curscol' ] ) - 2

# Vim stops shifting the popup to the left if we turn on soft-wrapping.
# Instead, we want to first shift the popup to the left and then
# and then turn on wrapping.
max_line_length = len( max(

Check warning on line 165 in python/ycm/signature_help.py

View check run for this annotation

Codecov / codecov/patch

python/ycm/signature_help.py#L165

Added line #L165 was not covered by tests
buf_lines,
key = lambda item: len( item[ 'text' ] ) )[ 'text' ] )
vim_width = vimsupport.GetIntValue( '&columns' )
line_available = vim_width - int( screen_pos[ 'col' ] )
if max_line_length > line_available:
col = vim_width - max_line_length

Check warning on line 171 in python/ycm/signature_help.py

View check run for this annotation

Codecov / codecov/patch

python/ycm/signature_help.py#L168-L171

Added lines #L168 - L171 were not covered by tests

if col <= 0:
col = 1

Expand All @@ -172,6 +183,7 @@
# cursorline. So instead, we manually set 'cursorline' in the popup window
# and enable syntax based on the current file syntax)
"flip": 1,
"fixed": 1,
"padding": [ 0, 1, 0, 1 ], # Pad 1 char in X axis to match completion menu
"hidden": int( state.state == SignatureHelpState.ACTIVE_SUPPRESSED )
}
Expand All @@ -196,7 +208,7 @@

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

return state