MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / patchTransaction

Function patchTransaction

web/src/lib/collab/patchApply.ts:284–289  ·  view source on GitHub ↗
(state: EditorState, hunks: PatchHunk[])

Source from the content-addressed store, hash-verified

282 * the plan read) are still valid when it lands.
283 */
284export function patchTransaction(state: EditorState, hunks: PatchHunk[]): Transaction | null {
285 if (hunks.length === 0) return null;
286 const tr = state.tr;
287 for (let k = hunks.length - 1; k >= 0; k--) tr.replaceWith(hunks[k].from, hunks[k].to, hunks[k].slice);
288 return tr;
289}
290
291/** Plans and applies the patch to the live editor in ONE transaction. */
292export function applyPatch(editor: Editor, edits: PatchEdit[], ctx: PatchContext): PatchApplied | PatchRefusal {

Callers 1

applyPatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected