diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 00:03:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 00:03:29 -0300 |
| commit | 3a3601f984d25f1e03cee3ac47da7eeb2548e511 (patch) | |
| tree | 445331cb8ad346989c4e4f6a3ceff54411064e4a /core/File.zig | |
| parent | 8a1f65a2d374796b9b5559c4aab87c8d1e8f6e68 (diff) | |
| parent | 528530ed065b2059d16b08efd92103d1dbbccc31 (diff) | |
| download | pardes-3a3601f984d25f1e03cee3ac47da7eeb2548e511.tar.gz pardes-3a3601f984d25f1e03cee3ac47da7eeb2548e511.zip | |
integration: a far client's seven small faults on the renamed tree: pardes-far-faults (a refocus that no longer asks the session's host about a newer build; a drag in a kind's pane grown too short; a draw's token that no rollback takes back; a text's declarations dumped so a joined client's query reads what the session's does; a search that goes on at once on a far client; two tests of what cannot happen) and pardes-merge24, merged without a textual conflict; the coordinator's gate in the ledger (reorg/merge25)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/File.zig b/core/File.zig index 020985da..75d8049b 100644 --- a/core/File.zig +++ b/core/File.zig @@ -59,8 +59,13 @@ pub const History = struct { } }; -/// Owned syntax results. Excluded from dumps as State.context is derived. +/// Owned syntax results: a text's declarations at a revision. pub const ContextCache = struct { + /// Its revision is dumped and digested: a worker's parse is an input, + /// which a client joined since never saw, and a step reads what it + /// left (Query.ownerDecls). The declarations are made again from the + /// text at a load (`reload`), with the allocator that made them. + pub const replica = .{ .local = .{"allocator"}, .derived = .{"declarations"} }; allocator: ?std.mem.Allocator = null, declarations: []syntax.ContextDeclaration = &.{}, revision: ?u32 = null, @@ -70,6 +75,15 @@ pub const ContextCache = struct { self.* = .{}; } + /// A loaded text's (its revision the dump's): its declarations parsed + /// again where they are of the text it has. + pub fn reload(self: *ContextCache, gpa: std.mem.Allocator, path: []const u8, content: []const u8, revision: u32) void { + const at = self.revision orelse return; + if (at != revision) return; + const declarations = syntax.contextDeclarations(gpa, path, content) catch return; + self.replace(gpa, declarations, at); + } + /// Takes ownership of declarations allocated by gpa. pub fn replace(self: *ContextCache, gpa: std.mem.Allocator, declarations: []syntax.ContextDeclaration, revision: u32) void { self.deinit(); @@ -83,7 +97,7 @@ pub const State = struct { /// from the text whenever it is wanted. // Syntax caches must not load through the dump loader's core allocator. pub const replica = .{ - .derived = .{ "cap", "line_starts", "line_cap", "highlights", "highlight_start", "syntax_dirty", "context", "node_tree", "node_tree_revision", "node_tree_edits", "node_history", "tables" }, + .derived = .{ "cap", "line_starts", "line_cap", "highlights", "highlight_start", "syntax_dirty", "node_tree", "node_tree_revision", "node_tree_edits", "node_history", "tables" }, // Big texts, dumped and sent by their hash (core/walk.zig). The // text is written in place by `replace`, but never while a join // sends it (memory.zig `pin`): then an edit puts a new buffer in |
