diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 23:49:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 01:35:13 -0300 |
| commit | 1ca3e68f38385952fa5a2ccc3dac883ba0be71e8 (patch) | |
| tree | bffbbf9e5e5b2b929d79bd81ea805c5288896623 /test/panes.zig | |
| parent | e567aadc19f58b1e36098388483294321f3502dd (diff) | |
| download | pardes-1ca3e68f38385952fa5a2ccc3dac883ba0be71e8.tar.gz pardes-1ca3e68f38385952fa5a2ccc3dac883ba0be71e8.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/test/panes.zig b/test/panes.zig index de9d3aea..378229ac 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -44,7 +44,7 @@ const TagLayerTests = struct { const layer = try findLayer(p, .pane, 0); const text = try pardes.tagline.tagText(p, frame.allocator(), pane); const at = std.mem.indexOf(u8, text, "END").?; - const col = panes.File.displayWidth(text[0..at]); + const col = panes.File.displayWidth(config.tab_width, text[0..at]); try std.testing.expect(col > p.view().rects[0].w); try std.testing.expect(col + 3 < layer.cols); try std.testing.expectEqualStrings("E", layer.cells[col].grapheme()); @@ -107,7 +107,7 @@ const TagLayerTests = struct { p.update(.{ .mouse = mouse(layer, beyond_x, .release) }); try std.testing.expectEqual(@as(usize, 0), p.view().active); const end_col = left_layer.capacity(p.view().row_metrics) - 1; - try std.testing.expectEqual(panes.File.rawAtDisplay(left_text, end_col), @as(usize, @intCast(left.tag.cur_col))); + try std.testing.expectEqual(panes.File.rawAtDisplay(config.tab_width, left_text, end_col), @as(usize, @intCast(left.tag.cur_col))); try std.testing.expect(left.sel[0].state == .done and left.sel[0].r0 == 0); p.update(.{ .key = .{ .cp = Key.escape } }); const long = &@as([60]u8, @splat('a')) ++ "ηEND"; @@ -171,7 +171,7 @@ const BodyHitTests = struct { try std.testing.expectEqual(first.row, second.row); const top = pane.scroll(); for ([_]u16{ 0, 1 }) |row| { - const expected = pane.wrapAt(row).line; + const expected = pane.wrapAt(config.tab_width, row).line; p.update(.{ .mouse = mouse(layer, row, 2, .press) }); p.update(.{ .mouse = mouse(layer, row, 2, .release) }); try std.testing.expectEqual(expected, pane.body.cur_row); @@ -179,7 +179,7 @@ const BodyHitTests = struct { } const last = pane.body_visible_rows - 1; try std.testing.expect(last >= pane.rows); - const expected = pane.wrapAt(last).line; + const expected = pane.wrapAt(config.tab_width, last).line; const prefix = panes.File.gutterWidth(pane); p.update(.{ .mouse = mouse(layer, last - 1, prefix + 11, .press) }); // Release at a different source row without an intermediate drag event. @@ -217,14 +217,14 @@ const LineNumberLookTests = struct { // A header row's number is its declaration's own source line, not the // body line it sits over (`pub fn work(` is line 1); a body row's is // its own. - try std.testing.expectEqual(@as(i32, 1), pane.wrapAt(1).line); + try std.testing.expectEqual(@as(i32, 1), pane.wrapAt(config.tab_width, 1).line); const rows = [_]u16{ 1, pane.context_rows + 3 }; for (rows) |row| { // Each Look recentres the view; come back under the headers. pane.scrollBy(30 - pane.scroll()); _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); - const expected = pane.wrapAt(row).line; + const expected = pane.wrapAt(config.tab_width, row).line; var press = BodyHitTests.mouse(&p.surface.body_layers[0], row, 1, .press); press.button = .right; var release = BodyHitTests.mouse(&p.surface.body_layers[0], row, 1, .release); @@ -274,7 +274,7 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(u16, 4), layer.context_rows); for ([_]i32{ 0, 4, 5, 6 }, 0..) |source_row, index| { const row: u16 = @intCast(index); - try std.testing.expectEqual(source_row, pane.wrapAt(row).line); + try std.testing.expectEqual(source_row, pane.wrapAt(config.tab_width, row).line); try std.testing.expectEqual(index == 0 or index == 3, layer.hasContextBorderAfter(row)); const y = layer.rowTop(row, 20, 10) + 9.5; const x = @as(f32, @floatFromInt(layer.viewport.x)) * 10 + 5; @@ -304,10 +304,10 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expectEqual(@as(i32, 59), pane.body.cur_row); const surface = try p.render(frame.allocator()); - const visible = pane.wrapRow(pane.body.cur_row, pane.body.cur_col); + const visible = pane.wrapRow(config.tab_width, pane.body.cur_row, pane.body.cur_col); try std.testing.expect(visible.row >= pane.context_rows); try std.testing.expect(visible.row < pane.rows); - try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(visible.row).line); + try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(config.tab_width, visible.row).line); const cursor = surface.cursor orelse return error.MissingLookCursor; const rect = p.view().rects[0]; const y = p.bodyTop(pane, rect); @@ -330,8 +330,8 @@ const TreeContextTests = struct { p.sync(); _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 4), pane.context_rows); - for (0..4) |row| try std.testing.expectEqual(@as(i32, @intCast(row)), pane.wrapAt(@intCast(row)).line); - try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(pane.context_rows).line); + for (0..4) |row| try std.testing.expectEqual(@as(i32, @intCast(row)), pane.wrapAt(config.tab_width, @intCast(row)).line); + try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(config.tab_width, pane.context_rows).line); const rect = p.view().rects[0]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); const y = p.bodyTop(pane, rect); @@ -357,10 +357,10 @@ const TreeContextTests = struct { _ = try p.render(frame.allocator()); try std.testing.expect(pane.context_rows <= previous); previous = pane.context_rows; - try std.testing.expectEqual(pane.scroll(), pane.wrapAt(pane.context_rows).line); + try std.testing.expectEqual(pane.scroll(), pane.wrapAt(config.tab_width, pane.context_rows).line); } try std.testing.expectEqual(@as(u16, 0), pane.context_rows); - try std.testing.expectEqual(@as(i32, 0), pane.wrapRow(0, pane.body.cur_col).row); + try std.testing.expectEqual(@as(i32, 0), pane.wrapRow(config.tab_width, 0, pane.body.cur_col).row); try std.testing.expect(p.executeBuiltinLine(0, "TreeContext")); pane.scrollBy(7); _ = try p.render(frame.allocator()); @@ -403,7 +403,7 @@ const TreeContextTests = struct { p.sync(); _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 0), pane.context_rows); - try std.testing.expectEqual(pane.scroll(), pane.wrapAt(0).line); + try std.testing.expectEqual(pane.scroll(), pane.wrapAt(config.tab_width, 0).line); } test "TreeContext clipped headers leave wrapped body cursor coordinates intact" { @@ -422,8 +422,8 @@ const TreeContextTests = struct { p.sync(); const surface = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 1), pane.context_rows); - try std.testing.expectEqual(@as(i32, 2), pane.wrapAt(1).line); - try std.testing.expectEqual(@as(i32, 2), pane.wrapAt(2).line); + try std.testing.expectEqual(@as(i32, 2), pane.wrapAt(config.tab_width, 1).line); + try std.testing.expectEqual(@as(i32, 2), pane.wrapAt(config.tab_width, 2).line); var target: ?struct { x: u16, y: u16 } = null; for (0..surface.rows) |row| for (0..surface.cols) |col| { if (std.mem.eql(u8, surface.at(@intCast(col), @intCast(row)).grapheme(), "η")) @@ -817,8 +817,8 @@ const TagNameTintTests = struct { var at: usize = 0; while (at < line.len) : (at = modal.nextGrapheme(line, at)) { const real = shown.toReal(line_start + at); - const start: i32 = @intCast(panes.File.rawDisplayCol(line, at)); - const end = start + @as(i32, @intCast(panes.File.displayWidth(line[at..modal.nextGrapheme(line, at)]))); + const start: i32 = @intCast(panes.File.rawDisplayCol(p.settings.tab, line, at)); + const end = start + @as(i32, @intCast(panes.File.displayWidth(p.settings.tab, line[at..modal.nextGrapheme(line, at)]))); var col = start; while (col < end and col < rect.w - pardes.TAG_TEXT_INSET) : (col += 1) { const in_name = real > base and real < name.len; @@ -868,7 +868,7 @@ const TagNameTintTests = struct { defer arena.deinit(); const shown = try pardes.tagline.shownTag(p, arena.allocator(), pane); const pos = modal.positionAt(shown.text, shown.fromReal(@intCast(pane.input.cur_col))); - const col: i32 = @intCast(panes.File.rawDisplayCol(modal.lineSlice(shown.text, pos.row), pos.col)); + const col: i32 = @intCast(panes.File.rawDisplayCol(config.tab_width, modal.lineSlice(shown.text, pos.row), pos.col)); pane.sel[0] = .{ .state = .done, .c0 = col, .c1 = col + 1, .r0 = @intCast(pos.row), .r1 = @intCast(pos.row) }; const surface = try p.render(arena.allocator()); const x = p.view().rects[0].x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(col)); @@ -1624,33 +1624,33 @@ const FileTests = struct { test "display columns map complete Unicode graphemes" { const text = "Γ©ηe\u{301}x"; - try std.testing.expectEqual(@as(usize, 5), displayWidth(text)); - try std.testing.expectEqual(@as(usize, 0), byteAtDisplay(text, 0)); - try std.testing.expectEqual(@as(usize, 2), byteAtDisplay(text, 1)); - try std.testing.expectEqual(@as(usize, 2), byteAtDisplay(text, 2)); - try std.testing.expectEqual(@as(usize, 5), byteAtDisplay(text, 3)); - try std.testing.expectEqual(@as(usize, 8), byteAtDisplay(text, 4)); - try std.testing.expectEqual(text.len, byteAtDisplay(text, 5)); - try std.testing.expectEqual(@as(usize, 3), rawDisplayCol(text, 5)); - try std.testing.expectEqual(@as(usize, 5), rawAtDisplay(text, 3)); + try std.testing.expectEqual(@as(usize, 5), displayWidth(config.tab_width, text)); + try std.testing.expectEqual(@as(usize, 0), byteAtDisplay(config.tab_width, text, 0)); + try std.testing.expectEqual(@as(usize, 2), byteAtDisplay(config.tab_width, text, 1)); + try std.testing.expectEqual(@as(usize, 2), byteAtDisplay(config.tab_width, text, 2)); + try std.testing.expectEqual(@as(usize, 5), byteAtDisplay(config.tab_width, text, 3)); + try std.testing.expectEqual(@as(usize, 8), byteAtDisplay(config.tab_width, text, 4)); + try std.testing.expectEqual(text.len, byteAtDisplay(config.tab_width, text, 5)); + try std.testing.expectEqual(@as(usize, 3), rawDisplayCol(config.tab_width, text, 5)); + try std.testing.expectEqual(@as(usize, 5), rawAtDisplay(config.tab_width, text, 3)); // At the line's end and past it (virtual columns, one byte each). - try std.testing.expectEqual(text.len, rawAtDisplay(text, 5)); - try std.testing.expectEqual(text.len + 2, rawAtDisplay(text, 7)); - try std.testing.expectEqual(@as(usize, 2), graphemeDisplayWidth("π©\u{200d}π")); + try std.testing.expectEqual(text.len, rawAtDisplay(config.tab_width, text, 5)); + try std.testing.expectEqual(text.len + 2, rawAtDisplay(config.tab_width, text, 7)); + try std.testing.expectEqual(@as(usize, 2), graphemeDisplayWidth(config.tab_width, "π©\u{200d}π")); } test "visual rows partition a line at the breaks the body renders" { const line = "abcdefgh"; - try std.testing.expectEqual(VisualRow{ .start = 0, .end = line.len }, visualRow(line, 5, 0)); - try std.testing.expectEqual(VisualRow{ .start = 0, .end = 3 }, visualRow(line, 0, 3)); - try std.testing.expectEqual(VisualRow{ .start = 0, .end = 3 }, visualRow(line, 2, 3)); - try std.testing.expectEqual(VisualRow{ .start = 3, .end = 6 }, visualRow(line, 3, 3)); + try std.testing.expectEqual(VisualRow{ .start = 0, .end = line.len }, visualRow(config.tab_width, line, 5, 0)); + try std.testing.expectEqual(VisualRow{ .start = 0, .end = 3 }, visualRow(config.tab_width, line, 0, 3)); + try std.testing.expectEqual(VisualRow{ .start = 0, .end = 3 }, visualRow(config.tab_width, line, 2, 3)); + try std.testing.expectEqual(VisualRow{ .start = 3, .end = 6 }, visualRow(config.tab_width, line, 3, 3)); // Past the end (a cursor on the newline) names the LAST row, and a short // line is one row however narrow the pane is. - try std.testing.expectEqual(VisualRow{ .start = 6, .end = 8 }, visualRow(line, line.len, 3)); - try std.testing.expectEqual(VisualRow{ .start = 0, .end = 0 }, visualRow("", 0, 3)); + try std.testing.expectEqual(VisualRow{ .start = 6, .end = 8 }, visualRow(config.tab_width, line, line.len, 3)); + try std.testing.expectEqual(VisualRow{ .start = 0, .end = 0 }, visualRow(config.tab_width, "", 0, 3)); // A grapheme wider than the row still occupies exactly one row. - try std.testing.expectEqual(VisualRow{ .start = 0, .end = 4 }, visualRow("π©x", 0, 1)); + try std.testing.expectEqual(VisualRow{ .start = 0, .end = 4 }, visualRow(config.tab_width, "π©x", 0, 1)); } }; @@ -1674,7 +1674,7 @@ const OutputTests = struct { for (file.location_rows, 0..) |row, i| { const line = modal.lineSlice(file.content, i); try std.testing.expectEqual(.match, row.kind); - const current = panes.File.displayWidth(line[0..row.code_start]); + const current = panes.File.displayWidth(config.tab_width, line[0..row.code_start]); if (column) |previous| try std.testing.expectEqual(previous, current); column = current; const expected = if (std.mem.eql(u8, row.path, "/η.zig")) " first" else "\tsecond"; @@ -1696,7 +1696,7 @@ const OutputTests = struct { try std.testing.expectEqual(@as(usize, 3), file.location_rows.len); const match = file.location_rows[1]; const match_line = modal.lineSlice(file.content, 1); - const alignment = panes.File.displayWidth(match_line[0..match.code_start]); + const alignment = panes.File.displayWidth(config.tab_width, match_line[0..match.code_start]); try std.testing.expect(match.location_end > 0); try std.testing.expect(std.mem.startsWith(u8, match_line, path)); for (file.location_rows, 0..) |row, index| { @@ -1704,7 +1704,7 @@ const OutputTests = struct { try std.testing.expectEqualStrings(path, row.path); try std.testing.expectEqual(index + 1, row.at.line); try std.testing.expect(!row.declaration); - try std.testing.expectEqual(alignment, panes.File.displayWidth(line[0..row.code_start])); + try std.testing.expectEqual(alignment, panes.File.displayWidth(config.tab_width, line[0..row.code_start])); try std.testing.expectEqualStrings(modal.lineSlice(source, index), line[row.code_start..]); if (index != 1) { try std.testing.expectEqual(@as(usize, 0), row.location_end); @@ -1834,11 +1834,11 @@ const OutputTests = struct { defer frame.deinit(); _ = try p.render(frame.allocator()); const wrapped = for (0..result.wrap_n) |vr| { - const w = result.wrapAt(@intCast(vr)); + const w = result.wrapAt(config.tab_width, @intCast(vr)); if (w.line == 0 and w.pad > 0 and w.at < file.location_rows[0].location_end) break vr; } else return error.MissingWrappedLocation; - const w = result.wrapAt(@intCast(wrapped)); - const shown = try panes.File.bodyText(frame.allocator(), result, file); + const w = result.wrapAt(config.tab_width, @intCast(wrapped)); + const shown = try panes.File.bodyText(config.tab_width, frame.allocator(), result, file); const shown_line = modal.lineSlice(shown, wrapped); try std.testing.expect(std.mem.startsWith(u8, shown_line[panes.File.gutterWidth(result)..], "β β ")); const rect = p.view().rects[result_id]; @@ -1990,7 +1990,7 @@ const OutputTests = struct { var alignment: ?usize = null; for (file.location_rows, 0..) |row, index| { const line = modal.lineSlice(file.content, index); - const width = panes.File.displayWidth(line[0..row.code_start]); + const width = panes.File.displayWidth(config.tab_width, line[0..row.code_start]); if (alignment) |previous| try std.testing.expectEqual(previous, width); alignment = width; try std.testing.expect(!std.mem.startsWith(u8, line, "| ")); @@ -2055,7 +2055,7 @@ const OutputTests = struct { for (file.highlights[start + row.code_start .. start + line.len]) |style| try std.testing.expectEqual(@as(u8, 0), style); const local = std.mem.indexOfNone(u8, line[row.code_start..], " \t") orelse continue; - const x = rect.x + config.GUTTER + panes.File.gutterWidth(result) + @as(u16, @intCast(panes.File.displayWidth(line[0 .. row.code_start + local]))); + const x = rect.x + config.GUTTER + panes.File.gutterWidth(result) + @as(u16, @intCast(panes.File.displayWidth(config.tab_width, line[0 .. row.code_start + local]))); const y = body_y + @as(u16, @intCast(index)); const cell = surface.at(x, y); try std.testing.expect(!cell.style.bold); |
