Skip to main content

Module edit

Module edit 

Source
Expand description

Shared edit engine: byte-offset conversion, content replacement, syntax validation, and auto-backup orchestration.

Used by write, edit_symbol, edit_match, and batch commands.

Structs§

DryRunResult
Result of a dry-run diff computation.
WriteResult
Result of the write → format → validate pipeline.

Functions§

auto_backup
Snapshot the file into the backup store before mutation.
compute_diff_info
Compute diff info between before/after content for UI metadata. Returns a JSON value with before, after, additions, deletions. For files >512KB, omits full content and returns only counts.
dry_run_diff
Compute a unified diff between original and proposed content, plus syntax validation.
is_dry_run
Extract the dry_run boolean from request params.
line_col_to_byte
Convert 0-indexed line/col to a byte offset within source.
replace_byte_range
Replace bytes in [start..end) with replacement.
validate_syntax
Validate syntax of a file using a fresh FileParser (D023).
validate_syntax_str
Validate syntax of an in-memory string without touching disk.
wants_diff
Check if the caller requested diff info in the response.
write_format_only
Format an already-written file (no re-write) without re-writing or validating. Returns Ok(true) if formatting was applied, Ok(false) if skipped.
write_format_validate
Write content to disk, auto-format, then validate syntax.