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

Completer after another completer.

Open
#1,765 0 comments 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

Hi, I wanted to use two completers one after another, but I'm not able to do that. FilesCompleter is my custom completer. After supplying the the file I want to trigger another completer BlockCompleter, but I don't know how to achieve that.

I tried following:

completer = NestedCompleter.from_nested_dict({
    'show': {
        'file': {
            FilesCompleter(): BlockCompleter()
        }
    },
})

But it gives me an error:

Exception 'FilesCompleter' object has no attribute 'lower'

Also another problem that I face is that for BlockCompleter to work I need result of FilesCompleter, but any of document methods or fields does not contain anything before the cursor position - eg. document.text is empty until i start typing.

What is the best way to achieve what I need?

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 NestedCompleter.from_nested_dict and the Completer/document APIs mentioned in the report. Reproduce the sequence using FilesCompleter followed by BlockCompleter, then determine whether the supported result should be an implementation change or documented composition pattern; done means the first completer's result is available to the second.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.