Completion menu rows - Clean up multi-column completion display, especially predictable height #1271
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Replace
PromptSessionparameterreserve_space_for_menu, which wasn't really working, with a new parametercompletion_menu_rowsthat has slightly different semantics. Additional layout fixes affecting bothCompletionMenuandMultiColumnCompletionMenunoted below.Parameter
completion_menu_rowslimits the number of rows that a completion menu will display, default 5. It applies equally toCompletionMenuandMultiColumnCompletionMenu. The point of putting a limit on number of rows is that it will render faster and users wouldn't read through a really long completion list anyway, they'll type a few more characters to narrow it down. Other changes ensure that the number of rows will not be reduced when at/near the bottom of the screen. The parameter can be specified onPromptSession.prompt{()orPromptSession.prompt_async()as well. Old parameterreserve_space_for_menuproduces aDeprecationWarningif specified, though the value is used for the new behavior.Other changes in the PR:
completion.Completion.display_meta_textreturnsNone, not empty string if Completion has no meta data. This prevents completion menus from displaying an extra blank line if no completion had meta data.containers.Float-- new optiondont_shrink_height: bool = False. IfTrue, height of Float will not be reduced if it wouldn't fit inFloatContainer. Instead, its preferred height will be considered in the preferred height of theFloatContainer. Default isFalse, the prior behavior. PromptSession layout uses this to ensure completion menus are not shrunk at bottom of screen.layout.MultiColumnCompletionMenu-- new optionmax_rows: int = 5specifies an upper limit on number of rows in the completion menu. Similar to effect ofmax_heightinlayout.CompletionMenu. Also changed the column width calculation to handle outliers in length of completions more gracefully.