Skip to content
1 min read · 113 words

Function: applyUpdateHunks() ​

ts
function applyUpdateHunks(inputText: string, hunks: ParsedHunk[]): string;

Defined in: src/lib/patch/index.ts:324

Apply an update operation's hunks to inputText. Context matching is exact and rejects ambiguity: a hunk whose old-lines match more than one location past the cursor fails rather than guessing.

The input's line-ending convention is preserved: a file containing CRLF is rejoined with CRLF, so a one-line edit stays a one-line diff rather than a whole-file newline rewrite.

Parameters ​

ParameterTypeDescription
inputTextstringThe file's current text.
hunksParsedHunk[]The parsed hunks, in order.

Returns ​

string

The patched text, using the input's dominant line terminator.