prompt-toolkit / prompt-toolkit/python-prompt-toolkit

How to dynamically set complete_style?

Open
#893 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

According to the following code, I know how to set complete_style.
https://github.com/prompt-toolkit/python-prompt-toolkit/blob/511173b37bf0a98db9af2ca40492bba4a60072f9/examples/prompts/auto-completion/colored-completions.py#L35
Then is there a way to set the complete_style dynamically?
For example, when the get_completions function returns less than 10 elements, apply CompleteStyle.COLUMN, otherwise use CompleteStyle.READLINE_LIKE

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked examples/prompts/auto-completion/colored-completions.py example around line 35, then trace how CompleteStyle and get_completions are used. Done means establishing whether the completion style can be selected from the number of returned elements, with COLUMN used below 10 and READLINE_LIKE otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.