summaryrefslogtreecommitdiff
path: root/core/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/dump.zig')
-rw-r--r--core/dump.zig50
1 files changed, 42 insertions, 8 deletions
diff --git a/core/dump.zig b/core/dump.zig
index 69eda35e..0cefa157 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -635,6 +635,7 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ
var on_disk: OnDisk = @splat(false);
const p = try loadKnowing(gpa, opts, bytes, &notes, &on_disk);
errdefer p.deinit();
+ dropOldTags(p);
// The 9P state its requests made was its connections', which do not
// come with it (a client's join loads alone, and keeps it).
p.fs.forget(gpa);
@@ -657,6 +658,36 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ
return p;
}
+/// A build before UX K' kept a tag's command words as its own text: one a
+/// dump restores equal to what its kind's tag said then (tagline.kindTail)
+/// is dropped, its words computed now (K'1); any other is the user's text,
+/// kept as it is. Here, where a Restore, a start from a dump and an
+/// Upgrade load (a replica's join loads its authority's, dropped there).
+/// The window's and the columns' tags the same (UX K'2): the window row of
+/// either build, with its `Restore <path>` or without, and the column tag
+/// it had.
+fn dropOldTags(p: *Pardes) void {
+ for (p.panes) |slot| if (slot) |pane| if (pane.tag.own) |own| {
+ if (std.mem.eql(u8, own, pardes.tagline.kindTail(pane))) dropOwn(p, &pane.tag);
+ };
+ const window: []const u8 = p.global_tag.own orelse "";
+ for ([_][]const u8{ pardes.config.topbar_window_str, pardes.config.topbar_terminal_str }) |old| {
+ if (!std.mem.startsWith(u8, window, old)) continue;
+ if (window.len != old.len and !std.mem.startsWith(u8, window[old.len..], " Restore ")) continue;
+ dropOwn(p, &p.global_tag);
+ break;
+ }
+ for (&p.views) |*slot| if (slot.*) |*v| for (v.col_tags[0..v.ncol]) |*t| {
+ if (t.own) |own| if (std.mem.eql(u8, own, pardes.tagline.column_tag_default)) dropOwn(p, t);
+ };
+}
+
+fn dropOwn(p: *Pardes, t: *pardes.panes.Text) void {
+ p.gpa.free(t.own.?);
+ t.own = null;
+ t.cur_pinned = false;
+}
+
/// A loaded core given to this host (with `revivePane` for each of its
/// panes): the store and Recent read (a Restore's carried from the session
/// it replaces, with its state file) and its ThemeFile asked for again. An
@@ -714,8 +745,9 @@ fn reviveSession(p: *Pardes, previous: ?*Pardes, resumed: bool) !void {
}
/// A loaded pane given to this host: a terminal a new shell in its old
-/// one's directory under its history, a file watched again (one changed on
-/// disk since comes back as it is now, one unsaved is marked changed), a
+/// one's directory under its history, a file watched again and its
+/// language's server started (one changed on disk since comes back as it
+/// is now, one unsaved is marked changed), a
/// kind's pane opened again (a PDF a build before the pdf addon dumped, as
/// the addon's).
fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool) void {
@@ -758,6 +790,7 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool
} else |_| {}
}
p.emit(.{ .watch = .{ .pane = .at(id), .on = true } });
+ p.emit(.{ .lsp_open = .{ .pane = .at(id) } });
// Its file gone from disk since the dump: its text is nowhere else, so
// it is said deleted, and Del, Exit and Restore ask first. One never on
// disk (a name not yet saved) comes back as it was.
@@ -1375,7 +1408,7 @@ test "restored syntax context caches are rebuilt from the text rather than loade
const f = &pane.file.?;
const declarations = try p.tree_sitter_gpa.alloc(pardes.syntax.ContextDeclaration, 1);
@memset(std.mem.sliceAsBytes(declarations), 0);
- f.context.replace(p.tree_sitter_gpa, declarations, f.revision);
+ f.context.replace(p.tree_sitter_gpa, .{ .declarations = declarations }, f.revision);
// Older builds persisted these two fields; the schema reader must skip them too.
const OldFile = struct {
path: []const u8,
@@ -1401,13 +1434,14 @@ test "restored syntax context caches are rebuilt from the text rather than loade
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);
+ // This build's: the revision kept, the declarations and the symbols
+ // parsed again from the text, with the syntax allocator.
+ var want = try pardes.syntax.context(syntax_gpa.allocator(), f.path, f.content);
+ defer want.deinit(syntax_gpa.allocator());
for (q.panes) |slot| if (slot) |restored| if (restored.file) |file| {
try std.testing.expectEqual(f.context.revision, file.context.revision);
- try std.testing.expectEqualSlices(pardes.syntax.ContextDeclaration, want, file.context.declarations);
+ try std.testing.expectEqualSlices(pardes.syntax.ContextDeclaration, want.declarations, file.context.declarations);
+ try std.testing.expectEqualSlices(pardes.syntax.Symbol, want.symbols, file.context.symbols);
};
}