def AdjustCandidateInsertionText(candidates):
 def NewCandidateInsertionText(to_insert, text_after_cursor):
  overlap_len = OverlapLength(to_insert, text_after_cursor)
  if overlap_len:
   return to_insert[:(- overlap_len)]
  return to_insert
 text_after_cursor = vimsupport.TextAfterCursor()
 if (not text_after_cursor):
  return candidates
 new_candidates = []
 for candidate in candidates:
  if isinstance(candidate, dict):
   new_candidate = candidate.copy()
   if (u'abbr' not in new_candidate):
    new_candidate[u'abbr'] = new_candidate[u'word']
   new_candidate[u'word'] = NewCandidateInsertionText(new_candidate[u'word'], text_after_cursor)
   new_candidates.append(new_candidate)
  elif (isinstance(candidate, str) or isinstance(candidate, bytes)):
   new_candidates.append({u'abbr': candidate, u'word': NewCandidateInsertionText(candidate, text_after_cursor)})
 return new_candidates

def AdjustCandidateInsertionText ( candidates ) : def NewCandidateInsertionText ( to_insert , text_after_cursor ) : overlap_len = OverlapLength ( to_insert , text_after_cursor ) if overlap_len : return to_insert [ : ( - overlap_len ) ] return to_insert text_after_cursor = vimsupport . TextAfterCursor ( ) if ( not text_after_cursor ) : return candidates new_candidates = [ ] for candidate in candidates : if isinstance ( candidate , dict ) : new_candidate = candidate . copy ( ) if ( u'abbr' not in new_candidate ) : new_candidate [ u'abbr' ] = new_candidate [ u'word' ] new_candidate [ u'word' ] = NewCandidateInsertionText ( new_candidate [ u'word' ] , text_after_cursor ) new_candidates . append ( new_candidate ) elif ( isinstance ( candidate , str ) or isinstance ( candidate , bytes ) ) : new_candidates . append ( { u'abbr' : candidate , u'word' : NewCandidateInsertionText ( candidate , text_after_cursor ) } ) return new_candidates
this function adjusts the candidate insertion text to take into account the text thats currently in front of the cursor .