From 1ca3e68f38385952fa5a2ccc3dac883ba0be71e8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 18 Nov 2026 23:49:29 -0300 Subject: core: nothing of a core is a process global, the three that were (pardes-probes P3, the reorganisation's 12c): config.tab_now goes, a tab's width is the core's settings.tab handed to every width function as `tab` (File.graphemeDisplayWidth and the 73 functions above it, test helpers among them, that had no core to read it from gained the parameter; an Editor, a Surface and the hunks' Ctx carry it; render sets Surface.tab; graphemeDisplayWidth asks its one printable ASCII byte before the tab, the two disjoint: with the tab first, as before, the parameter cost 0.2-1.7% instructions an operation in pardes-perf, with ASCII first the measured cells use 2-16% fewer than the base), so a rollback can no longer leave a stale width and replica.zig's hand-made put-back in toConfirmed goes; Addon.distrusted/ndistrusted become Addon.Distrusted, the client's own list, which its frontend owns across its joins and hands each core as Options.distrusted (in no tape, dump or digest: Options' replica .local); Kind.draw_tokens becomes each slot's `draws` (local: a draw is a frame's, so each process's count differs and no digest may hold it; the copy saves it with the slot); the two turn reads in a step stay, being shown unable to reach a client's state (the report); the soak's Proc keeps only the client's list (its tab_now and the global swaps go, forced); test/perf.zig follows three signatures, so unit-test's perf check now says BaselineHarnessMismatch until the baselines are recorded again; tui core-test 824/966 (142 skipped), shell-test 1001/1004, pane-test 183/184, behaviour-test 274/274 and --replay 274/274, process-test 2 of 144 failed (lspcomplete, lspcompletemoved), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, gui unit-test 1598/1602, lib-test, daemon.py plain, --far, --games, --window-clients pass Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Core.zig | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'core/Core.zig') diff --git a/core/Core.zig b/core/Core.zig index 39d09f21..a19453af 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -523,8 +523,6 @@ pub fn init(gpa: std.mem.Allocator, opts: Options) !*Pardes { } fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { - // A new session draws a tab at the default until `Tab` says otherwise. - config.tab_now = config.tab_width; const p = try create(gpa, opts); errdefer p.deinit(); p.boot = Boot.of(opts); @@ -1604,7 +1602,7 @@ pub fn update(p: *Pardes, ev: Event) void { .tick => { Stream.step(p); Messages.advanceMessages(p); - for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.tables.step(pane.gpa, f); + for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.tables.step(p.settings.tab, pane.gpa, f); for (0..p.panes.len) |id| exec.flushReplEnter(p, id, false); }, else => {}, @@ -1858,7 +1856,7 @@ pub fn sync(p: *Pardes) void { var caret_row: usize = @intCast(@max(0, pane.tag.cur_row)); if (prefix) |made| wrap: { const whole = std.mem.concat(wa, u8, &.{ made, tagline.curTail(pane) }) catch break :wrap; - const shown = tagline.wrapTag(wa, whole, tagline.tagWidth(p, id)) catch break :wrap; + const shown = tagline.wrapTag(p.settings.tab, wa, whole, tagline.tagWidth(p, id)) catch break :wrap; lines = shown.rows(); // Collapsed, one row, as acme's Tagup sets taglines to 1 // (plan9port text.c:786). @@ -2174,6 +2172,7 @@ pub const Boot = enum { }; pub const Options = struct { + pub const replica = .{ .local = .{"distrusted"} }; tty_only: bool = false, /// The first view's frontend is a window (`Pardes.frontend`), as a /// window's build says: an option, taped with the rest, so that a @@ -2215,6 +2214,9 @@ pub const Options = struct { recent_import: ?[]const u8 = null, startup_config_path: ?[]const u8 = null, image_allocator: ?std.mem.Allocator = null, + /// A client's: the kinds it caught breaking PA_PLAIN, its frontend's + /// list, which outlives each core it joins with. In no tape and no dump. + distrusted: ?*pardes.Addon.Distrusted = null, /// What the host's scan of the addon directories found (Addon.scan). addons: []const pardes.Kind.Loaded = &.{}, tree_sitter_allocator: ?std.mem.Allocator = null, @@ -2923,7 +2925,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe // Several selections executed at once: each is sent, not the first. { const text = try edit.flatSurface(p.editor(), &file.body); - file.body.setRanges(text, &.{ .{ .anchor = 0, .head = 8 }, .{ .anchor = 9, .head = 11 } }, &.{}, 0, true); + file.body.setRanges(config.tab_width, text, &.{ .{ .anchor = 0, .head = 8 }, .{ .anchor = 9, .head = 11 } }, &.{}, 0, true); try std.testing.expect(exec.chordEachSel(p, file, .Exec)); Sent.drain(p); try std.testing.expectEqualStrings("print(1)\rls\r", Sent.said(1)); @@ -3438,11 +3440,9 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 }); defer p.deinit(); - // The width is the process's: the next test starts from the default. - defer config.tab_now = config.tab_width; const pane = try p.setTestFile("\tx = 1\n"); try std.testing.expect(p.executeBuiltinLine(0, "Tab 8")); - try std.testing.expectEqual(@as(u16, 8), config.tab_now); + try std.testing.expectEqual(@as(u16, 8), p.settings.tab); var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); const surface = try p.render(frame.allocator()); @@ -3459,7 +3459,7 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T try std.testing.expectEqualStrings("Tab 8", pane.msg[0..pane.msg_len]); // Out of range: refused, the width kept. try std.testing.expect(p.executeBuiltinLine(0, "Tab 0")); - try std.testing.expectEqual(@as(u16, 8), config.tab_now); + try std.testing.expectEqual(@as(u16, 8), p.settings.tab); // The ctl read's tab column, and a Dump's settings. const ctl_text = @import("ninep/testing.zig").rd(p, ctlfs.Node.of(pane.serial, .ctl), 0, 4096).bytes; try std.testing.expect(std.mem.indexOf(u8, ctl_text, " 8 ") != null); @@ -3467,7 +3467,6 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T const restored = try dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); defer restored.deinit(); try std.testing.expectEqual(@as(u16, 8), restored.settings.tab); - try std.testing.expectEqual(@as(u16, 8), config.tab_now); } test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" { @@ -3504,7 +3503,7 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" { const line = modal.lineSlice(f.content, 0); const virtual: u16 = 3; - const blank_x = text_x + @as(u16, @intCast(pardes.panes.File.displayWidth(line))) + virtual; + const blank_x = text_x + @as(u16, @intCast(pardes.panes.File.displayWidth(config.tab_width, line))) + virtual; p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = blank_x, .row = body_y } }); p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = blank_x, .row = body_y } }); try std.testing.expectEqual(@as(i32, @intCast(line.len)), pane.body.cur_col); @@ -3518,7 +3517,7 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" { // The immediately-adjacent EOL cell and an in-line separator are blank // too. Pointer expansion must not lean left into the preceding word. - const adjacent: i32 = @intCast(config.PREFIX_W + pardes.panes.File.displayWidth(line)); + const adjacent: i32 = @intCast(config.PREFIX_W + pardes.panes.File.displayWidth(config.tab_width, line)); try std.testing.expect(look.expandedSel(p, pane, .{ .state = .dragging, .c0 = adjacent, .c1 = adjacent, .r0 = BOX_H, .r1 = BOX_H }) == null); const separator: i32 = @intCast(config.PREFIX_W + config.tab_width + "return".len); try std.testing.expect(look.expandedSel(p, pane, .{ .state = .dragging, .c0 = separator, .c1 = separator, .r0 = BOX_H, .r1 = BOX_H }) == null); @@ -3986,7 +3985,7 @@ test "leaving tty hides the prompt and keeps the command typed at it" { }.at; const bodyRowOf = struct { fn at(pp: *Pardes, pane: *Pane, needle: []const u8) ?[]const u8 { - const body = @import("body_layer.zig").bodyText(pp.scratch.allocator(), pane) catch return null; + const body = @import("body_layer.zig").bodyText(pp.settings.tab, pp.scratch.allocator(), pane) catch return null; var it = std.mem.splitScalar(u8, body, '\n'); while (it.next()) |r| if (std.mem.indexOf(u8, r, needle) != null) return r; return null; -- cgit v1.3