summaryrefslogtreecommitdiff
path: root/core/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/dump.zig')
-rw-r--r--core/dump.zig12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/dump.zig b/core/dump.zig
index a8dd170a..e6cdceec 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -406,6 +406,7 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes:
for (others) |o| gpa.free(o.panes);
gpa.free(others);
l.shared.shrinkRetainingCapacity(at);
+ for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.context.reload(p.tree_sitter_gpa, f.path, f.content, f.revision);
p.readSessionFacts();
return p;
}
@@ -491,6 +492,7 @@ fn loadImage(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: ?*
try views.undumpedOld(p, others, gpa);
}
l.made.shrinkRetainingCapacity(at);
+ for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.context.reload(p.tree_sitter_gpa, f.path, f.content, f.revision);
p.readSessionFacts();
return p;
}
@@ -1200,7 +1202,7 @@ test "an old dump's file, a byte dump, is read by -l and by a Restore of its pat
try std.testing.expectEqualSlices(u8, bytes, again);
}
-test "restored syntax context caches are rebuilt rather than loaded with the core allocator" {
+test "restored syntax context caches are rebuilt from the text rather than loaded with the core allocator" {
const gpa = std.testing.allocator;
var syntax_gpa: std.heap.DebugAllocator(.{}) = .init;
defer std.testing.expect(syntax_gpa.deinit() == .ok) catch @panic("syntax allocator leaked");
@@ -1237,9 +1239,13 @@ test "restored syntax context caches are rebuilt rather than loaded with the cor
defer gpa.free(bytes);
const q = try load(gpa, opts, bytes, null);
defer q.deinit();
+ // This build's: the revision kept, the declarations parsed again from
+ // the text, with the syntax allocator.
+ const want = try pardes.syntax.contextDeclarations(syntax_gpa.allocator(), f.path, f.content);
+ defer syntax_gpa.allocator().free(want);
for (q.panes) |slot| if (slot) |restored| if (restored.file) |file| {
- try std.testing.expectEqual(@as(usize, 0), file.context.declarations.len);
- try std.testing.expectEqual(@as(?u32, null), file.context.revision);
+ try std.testing.expectEqual(f.context.revision, file.context.revision);
+ try std.testing.expectEqualSlices(pardes.syntax.ContextDeclaration, want, file.context.declarations);
};
}