nicfit/shell/completion.py
def get_completions(self, document, complete_event):
        # Get word/text before cursor.
        if self.sentence:
            word_before_cursor = document.text_before_cursor
        else:
            word_before_cursor = document.get_word_before_cursor(WORD=self.WORD)

        if self.ignore_case:
            word_before_cursor = word_before_cursor.lower()

        def word_matches(word):
            """ True when the word before the cursor matches. """
            if self.ignore_case:
                word = word.lower()

            if self.match_middle:
                return word_before_cursor in word
            else:
                return word.startswith(word_before_cursor)

        '''
        log.debug("------------------------------------------------------")
        log.debug(f"** WORD {self.WORD}")
        log.debug(f"** words {self.words}")
        log.debug(f"** word_before_cursor {word_before_cursor}")
        '''
        words = self._words_callable() if self._words_callable else self.words

        for a in words:
            if word_matches(a):
                display_meta = self.meta_dict.get(a, '')
                log.debug(f"MATCH: {a}, {-len(word_before_cursor)},"
                          f" meta: {display_meta}")
                yield Completion(self.quote(a), -len(word_before_cursor),
                                 display_meta=display_meta)
def get_completions(self, document, complete_event):
        # Get word/text before cursor.
        if self.sentence:
            word_before_cursor = document.text_before_cursor
        else:
            word_before_cursor = document.get_word_before_cursor(WORD=self.WORD)

        if self.ignore_case:
            word_before_cursor = word_before_cursor.lower()

        def word_matches(word):
            """ True when the word before the cursor matches. """
            if self.ignore_case:
                word = word.lower()

            if self.match_middle:
                return word_before_cursor in word
            else:
                return word.startswith(word_before_cursor)

        '''
        log.debug("------------------------------------------------------")
        log.debug(f"** WORD {self.WORD}")
        log.debug(f"** words {self.words}")
        log.debug(f"** word_before_cursor {word_before_cursor}")
        '''
        words = self._words_callable() if self._words_callable else self.words

        for a in words:
            if word_matches(a):
                display_meta = self.meta_dict.get(a, '')
                log.debug(f"MATCH: {a}, {-len(word_before_cursor)},"
                          f" meta: {display_meta}")
                yield Completion(self.quote(a), -len(word_before_cursor),
                                 display_meta=display_meta)
def get_completions ( self , document , complete_event ) : # Get word/text before cursor. if self . sentence : word_before_cursor = document . text_before_cursor else : word_before_cursor = document . get_word_before_cursor ( WORD = self . WORD ) if self . ignore_case : word_before_cursor = word_before_cursor . lower ( ) def word_matches ( word ) : """ True when the word before the cursor matches. """ if self . ignore_case : word = word . lower ( ) if self . match_middle : return word_before_cursor in word else : return word . startswith ( word_before_cursor ) words = self . _words_callable ( ) if self . _words_callable else self . words for a in words : if word_matches ( a ) : display_meta = self . meta_dict . get ( a , '' ) log . debug ( f"MATCH: {a}, {-len(word_before_cursor)}," f" meta: {display_meta}" ) yield Completion ( self . quote ( a ) , - len ( word_before_cursor ) , display_meta = display_meta )
log.debug("------------------------------------------------------")
        log.debug(f"** WORD {self.WORD}")
        log.debug(f"** words {self.words}")
        log.debug(f"** word_before_cursor {word_before_cursor}")
log . debug ( ------------------------------------------------------ ) log . debug ( f ** WORD { self . WORD } ) log . debug ( f ** words { self . words } ) log . debug ( f ** word_before_cursor { word_before_cursor } )