MCPcopy
hub / github.com/SirVer/ultisnips / _is_pathological_diff_input

Function _is_pathological_diff_input

pythonx/UltiSnips/change_provider.py:39–49  ·  view source on GitHub ↗

Return True when running diff(old, new) would be both slow and structurally suspect — meaning the buffer has diverged from the snippet's tracked state in a way no reasonable replay can recover. Heuristic: the character-count delta exceeds what an interactive snippet edit could plaus

(old_lines, new_lines)

Source from the content-addressed store, hash-verified

37
38
39def _is_pathological_diff_input(old_lines, new_lines):
40 """Return True when running diff(old, new) would be both slow and
41 structurally suspect — meaning the buffer has diverged from the
42 snippet's tracked state in a way no reasonable replay can recover.
43
44 Heuristic: the character-count delta exceeds what an interactive
45 snippet edit could plausibly produce in a single CursorMoved cycle.
46 """
47 return (
48 abs(_joined_len(new_lines) - _joined_len(old_lines)) > _PATHOLOGICAL_CHAR_DELTA
49 )
50
51
52def diff(a, b, sline=0):

Calls 1

_joined_lenFunction · 0.85