MCPcopy Create free account
hub / github.com/HKUDS/OpenSpace / _apply_replacements

Function _apply_replacements

openspace/skill_engine/patch.py:740–750  ·  view source on GitHub ↗

Apply pre-sorted replacements in reverse order to avoid index shift.

(
    lines: List[str],
    replacements: List[Tuple[int, int, List[str]]],
)

Source from the content-addressed store, hash-verified

738 return replacements
739
740def _apply_replacements(
741 lines: List[str],
742 replacements: List[Tuple[int, int, List[str]]],
743) -> List[str]:
744 """Apply pre-sorted replacements in reverse order to avoid index shift."""
745 result = list(lines)
746 for start_idx, old_len, new_segment in reversed(replacements):
747 del result[start_idx: start_idx + old_len]
748 for j, line in enumerate(new_segment):
749 result.insert(start_idx + j, line)
750 return result
751
752def apply_update_chunks(
753 file_path: str,

Callers 1

apply_update_chunksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected