class_docstr: Completer which wraps around several other completers, and calls any the
  one that corresponds with the first word of the input.
  
  By combining multiple `NestedCompleter` instances, we can achieve multiple
  hierarchical levels of autocompletion. This is useful when `WordCompleter`
  is not sufficient.
  
  If you need multiple levels, check out the `from_nested_dict` classmethod.
class_docstr_tok: ["Completer","which","wraps","around","several","other","completers",",","and","calls","any","the","one","that","corresponds","with","the","first","word","of","the","input",".","By","combining","multiple","`","NestedCompleter","`","instances",",","we","can","achieve","multiple","hierarchical","levels","of","autocompletion",".","This","is","useful","when","`","WordCompleter","`","is","not","sufficient",".","If","you","need","multiple","levels",",","check","out","the","`","from_nested_dict","`","classmethod","."]
code: def get_completions(
      self, document: Document, complete_event: CompleteEvent
  ) -> Iterable[Completion]:
      # Split document.
      text = document.text_before_cursor.lstrip()
      stripped_len = len(document.text_before_cursor) - len(text)
  
      # If there is a space, check for the first term, and use a
      # subcompleter.
      if " " in text:
          first_term = text.split()[0]
          completer = self.options.get(first_term)
  
          # If we have a sub completer, use this for the completions.
          if completer is not None:
              remaining_text = text[len(first_term) :].lstrip()
              move_cursor = (
                  len(text) - len(remaining_text) + stripped_len
              )
  
              new_document = Document(
                  remaining_text,
                  cursor_position=document.cursor_position
                  - move_cursor,
              )
  
              yield from completer.get_completions(
                  new_document, complete_event
              )
  
      # No space in the input: behave exactly like `WordCompleter`.
      else:
          completer = WordCompleter(
              list(self.options.keys()), ignore_case=self.ignore_case
          )
          yield from completer.get_completions(document, complete_event)
  
file_path: catboost/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/nested.py
imports: from __future__ import annotations
  from typing import Any, Iterable, Mapping, Set, Union
  from prompt_toolkit.completion import CompleteEvent, Completer, Completion
  from prompt_toolkit.completion.word_completer import WordCompleter
  from prompt_toolkit.document import Document
label_desc: Use image node_id 4 for calling the NestedCompleter obj's underlying member method code with example usage: obj.get_completions(document, complete_event) without return types