diff options
Diffstat (limited to 'core/dump.zig')
| -rw-r--r-- | core/dump.zig | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/core/dump.zig b/core/dump.zig index ad436ac5..0cefa157 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -422,10 +422,8 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: const was = try l.get(OnDisk); if (on_disk) |out| out.* = was; const theme = try l.get([]const u8); - // This build's place for that theme; one it has not, its first. - p.settings.theme = for (colors.themes, 0..) |t, i| { - if (std.mem.eql(u8, t.name, theme)) break i; - } else if (p.settings.theme < colors.themes.len) p.settings.theme else 0; + // This build's place for that theme, a retired one's successor's. + p.settings.theme = colors.restoredIndex(theme, p.settings.theme); // A mount this process was started with stands; one of the same name // to elsewhere is refused, never silently put over it. for (mounts) |m| { @@ -515,9 +513,7 @@ fn loadImage(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: ?* if (on_disk) |out| out.* = was; const theme: []const u8 = if (try walk.Get.member(root, "theme")) |c| try l.get([]const u8, c) else ""; defer gpa.free(theme); - p.settings.theme = for (colors.themes, 0..) |t, i| { - if (std.mem.eql(u8, t.name, theme)) break i; - } else if (p.settings.theme < colors.themes.len) p.settings.theme else 0; + p.settings.theme = colors.restoredIndex(theme, p.settings.theme); for (mounts) |m| { const existing = for (p.fs.mounts.items) |e| { if (std.mem.eql(u8, e.name, m.name)) break e; @@ -749,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 { @@ -793,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. @@ -1410,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, @@ -1436,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); }; } |
