def _HasCompletionsThatCouldBeCompletedWithMoreText(self, completions): completed_item = vimsupport.GetVariableValue('v:completed_item') if not completed_item: return False completed_word = utils.ToUnicode(completed_item['word']) if not completed_word: return False # Sometimes CompleteDone is called after the next character is inserted. # If so, use inserted character to filter possible completions further. text = vimsupport.TextBeforeCursor() reject_exact_match = True if text and text[-1] != completed_word[-1]: reject_exact_match = False completed_word += text[-1] for completion in completions: word = utils.ToUnicode( ConvertCompletionDataToVimData(completion)['word']) if reject_exact_match and word == completed_word: continue if word.startswith(completed_word): return True return False
def _HasCompletionsThatCouldBeCompletedWithMoreText_OlderVim( self, completions): # No support for multiple line completions text = vimsupport.TextBeforeCursor() for completion in completions: word = ConvertCompletionDataToVimData(completion)['word'] for i in range(1, len(word) - 1): # Excluding full word if text[-1 * i:] == word[:i]: return True return False
def _FilterToMatchingCompletions_OlderVim(self, completions, full_match_only): """ Filter to completions matching the buffer text """ if full_match_only: return # Only supported in 7.4.774+ # No support for multiple line completions text = vimsupport.TextBeforeCursor() for completion in completions: word = completion["insertion_text"] # Trim complete-ending character if needed text = re.sub(r"[^a-zA-Z0-9_]$", "", text) buffer_text = text[-1 * len(word):] if buffer_text == word: yield completion
def TextBeforeCursor_EncodedUnicode_test( *args ): eq_( vimsupport.TextBeforeCursor(), u'ДД' )