def _HasCompletionsThatCouldBeCompletedWithMoreText( completed_item,
                                                     completions ):
  if not completed_item:
    return False

  completed_word = 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 index, completion in enumerate( completions ):
    word = ToUnicode(
        _ConvertCompletionDataToVimData( index, completion )[ 'word' ] )
    if reject_exact_match and word == completed_word:
      continue
    if word.startswith( completed_word ):
      return True
  return False
示例#2
0
def _HasCompletionsThatCouldBeCompletedWithMoreText(completed_item,
                                                    completions):
    if not completed_item:
        return False

    completed_word = 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 index, completion in enumerate(completions):
        word = ToUnicode(
            _ConvertCompletionDataToVimData(index, completion)['word'])
        if reject_exact_match and word == completed_word:
            continue
        if word.startswith(completed_word):
            return True
    return False
示例#3
0
def _PrepareTrigger( trigger ):
  trigger = ToUnicode( trigger )
  if trigger.startswith( TRIGGER_REGEX_PREFIX ):
    return re.compile( trigger[ len( TRIGGER_REGEX_PREFIX ) : ], re.UNICODE )
  return re.compile( re.escape( trigger ), re.UNICODE )
示例#4
0
def _PrepareTrigger( trigger ):
  trigger = ToUnicode( trigger )
  if trigger.startswith( TRIGGER_REGEX_PREFIX ):
    return re.compile( trigger[ len( TRIGGER_REGEX_PREFIX ) : ], re.UNICODE )
  return re.compile( re.escape( trigger ), re.UNICODE )