From 205b1d26b5be40424eace945a73867bdfefe90ce Mon Sep 17 00:00:00 2001 From: t Date: Wed, 25 Nov 2026 11:25:00 -0700 Subject: Anchor ghosts and alternatives to surrounding text, not byte offsets Ghosted text and alternatives are saved with context from the text around them, so an outside edit no longer sends the whole file to raw Markdown. A ghost with no clear place goes to Overflow. An alternatives group that cannot be matched is dropped; its text is not kept. HTML comments show dimmed in place, with their delimiters hidden until the caret enters them. Ctrl+/ on a comment uncomments it. Comments are left out of Lab and AI requests, except the one an alternatives target sits in. The metadata moves to format v3. Builds before this one show v3 files as raw Markdown, so install this build before saving. --- src/ghost_io.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/ghost_io.zig') diff --git a/src/ghost_io.zig b/src/ghost_io.zig index e5061ff..ff9f612 100644 --- a/src/ghost_io.zig +++ b/src/ghost_io.zig @@ -37,11 +37,8 @@ pub fn visible(allocator: Allocator, body: []const u8, ghosts: anytype) ![]const /// owns the returned slice. On failure, keep the original Markdown and metadata /// intact rather than continuing with a partially decoded document. /// -/// Offset-only records cannot detect edits that leave all insertion points in -/// bounds and on codepoint boundaries. In that case restore inserts all text at -/// the recorded positions, without guessing new ones. To reject such edits, -/// the caller must verify a separately stored digest of the visible bytes and -/// fall back to the original Markdown on mismatch. +/// Offsets alone cannot say whether the visible bytes were edited: the caller +/// must already know where each ghost belongs in these. pub fn restore(allocator: Allocator, body_visible: []const u8, ghosts: anytype) ![]const u8 { if (ghosts.len != 0 and !std.unicode.utf8ValidateSlice(body_visible)) return error.InvalidUtf8; var removed: usize = 0; -- cgit v1.3