MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / finish

Method finish

atomic-core/src/record/workflow/graph_op/builder.rs:288–334  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

286 /// ```
287 #[must_use]
288 pub fn finish(self) -> HunkBuildResult {
289 let mut result = HunkBuildResult::new();
290
291 for pending in self.pending {
292 let local = Local::new(&self.path, pending.display_line());
293 let encoding = self.options.encoding;
294
295 let graph_op = match pending.kind {
296 PendingChangeKind::Insert => {
297 // Use the new_edit_with_lines constructor to track which lines
298 // in the new content this graph_op covers. The caller will use this
299 // to calculate actual byte positions in the content buffer.
300 // old_start is the insertion point (insert AFTER this line in old content)
301 BuiltHunk::new_edit_with_lines(
302 local,
303 encoding,
304 pending.old_start,
305 pending.new_start,
306 pending.new_len,
307 )
308 }
309 PendingChangeKind::Delete => {
310 let deleted: Vec<usize> =
311 (pending.old_start..pending.old_start + pending.old_len).collect();
312 BuiltHunk::new_delete(local, encoding, deleted, pending.old_start)
313 }
314 PendingChangeKind::Replace => {
315 let deleted: Vec<usize> =
316 (pending.old_start..pending.old_start + pending.old_len).collect();
317 // Use the new_replace_with_lines constructor to track which lines
318 // in the new content this graph_op covers.
319 BuiltHunk::new_replace_with_lines(
320 local,
321 encoding,
322 deleted,
323 pending.old_start,
324 pending.new_start,
325 pending.new_len,
326 )
327 }
328 };
329
330 result.add_hunk(graph_op);
331 }
332
333 result
334 }
335
336 /// Reset the builder for reuse with a new file.
337 ///

Calls 2

display_lineMethod · 0.80
add_hunkMethod · 0.45