Esempio n. 1
0
 def get_completions(self, document: Document,
                     complete_event: CompleteEvent) -> Iterable[Completion]:
     prev_word_pos = document.find_previous_word_beginning()
     if (prev_word_pos is None and document.cursor_position != 0) or (
             prev_word_pos is not None
             and document.cursor_position + prev_word_pos != 0):
         return []
     for priority, entries_by_priority in self.shell.commands.items():
         for entry in entries_by_priority:
             if entry.startswith(document.text):
                 yield Completion(
                     entry,
                     start_position=0
                     if prev_word_pos is None else prev_word_pos,
                     style={
                         CommandEntryPriority.BASE: "",
                         CommandEntryPriority.ALIAS: "bg:ansibrightyellow",
                         CommandEntryPriority.USER_ALIAS:
                         "bg:ansibrightyellow",
                     }[priority],
                     selected_style={
                         CommandEntryPriority.BASE: "",
                         CommandEntryPriority.ALIAS: "bg:ansiyellow",
                         CommandEntryPriority.USER_ALIAS: "bg:ansiyellow",
                     }[priority],
                 )