Skip to content

Conversation

@bobhy
Copy link

@bobhy bobhy commented Oct 11, 2020

Replace PromptSession parameter reserve_space_for_menu, which wasn't really working, with a new parameter completion_menu_rows that has slightly different semantics. Additional layout fixes affecting both CompletionMenu and MultiColumnCompletionMenu noted below.

Parameter completion_menu_rows limits the number of rows that a completion menu will display, default 5. It applies equally to CompletionMenu and MultiColumnCompletionMenu. 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 on PromptSession.prompt{() or PromptSession.prompt_async() as well. Old parameter reserve_space_for_menu produces a DeprecationWarning if specified, though the value is used for the new behavior.

Other changes in the PR:

  • completion.Completion.display_meta_text returns None, 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 option dont_shrink_height: bool = False. If True, height of Float will not be reduced if it wouldn't fit in FloatContainer. Instead, its preferred height will be considered in the preferred height of the FloatContainer. Default is False, the prior behavior. PromptSession layout uses this to ensure completion menus are not shrunk at bottom of screen.
  • layout.MultiColumnCompletionMenu -- new option max_rows: int = 5 specifies an upper limit on number of rows in the completion menu. Similar to effect of max_height in layout.CompletionMenu. Also changed the column width calculation to handle outliers in length of completions more gracefully.
Bob Hyman added 6 commits October 14, 2020 21:51
height and width; PromptSession reserve_space_for_menu -> completion_menu_rows; FloatContainer height includes child floats.
whole float displayed at bottom of layout.
@bobhy bobhy force-pushed the completion_menu_rows branch from 284334c to 3ab8898 Compare October 15, 2020 04:53
@bobhy
Copy link
Author

bobhy commented Oct 16, 2020

Rebased on latest master. Added missing backward compatibility: reserve_space_for_menu can now be specified (but will provide the deprecation warning, as advertised).

@bobhy bobhy force-pushed the completion_menu_rows branch from 164103d to 20760cb Compare October 16, 2020 20:46
bobhy pushed a commit to bobhy/xonsh that referenced this pull request Oct 16, 2020
@ju-kreber
Copy link

ju-kreber commented Oct 25, 2020

This works really well for me, an issue with the completion dialogue is gone (xonsh/xonsh#3843) and the behavior of space reservation is improved.

@t184256
Copy link

t184256 commented Oct 27, 2020

Can confirm that this PR solves xonsh/xonsh#3810 and makes multi tab completion ellipsize long entries.

@Spriithy
Copy link

Spriithy commented Nov 1, 2020

Any chance this MR might be merged for the next release ?

@anki-code
Copy link

anki-code commented Apr 8, 2021

Hi @jonathanslenders! What do you think about this PR? Looks like many thumbups here.

@bobhy
Copy link
Author

bobhy commented Dec 17, 2024

I'm pretty sure this PR is stale, and I don't have time to push it any more. I'm gonna close it next week unless someone wants to take it over.

@anki-code
Copy link

I think the best thing is to convert it to draft instead of closing because it will keep the chance to be discovered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants