diff options
Diffstat (limited to 'core/Messages.zig')
| -rw-r--r-- | core/Messages.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index dd5c232a..6d8d570d 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -1330,6 +1330,34 @@ test "a burst of the same message is one message, counted, and moves nothing on try std.testing.expect(std.mem.endsWith(u8, row.text[0..row.left], "3 files \u{d7}10")); } +test "a question never adds a row to its tag: at every width the asking tag takes the rows the tag takes at rest, its answers always shown, the question cut before them" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 30 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const id = p.view().active; + // A short name: the tag's rows have room for it and the answers. + p.gpa.free(pane.file.?.path); + pane.file.?.path = try p.gpa.dupe(u8, "/t/c.zig"); + const f = &pane.file.?; + f.saved_hash = panes.File.fileHash(f); + for ([_]u21{ 'G', 'o', 'f', Key.escape }) |cp| p.update(.{ .key = .{ .cp = cp } }); + // The tag's own words cut to one, so the question is the longer. + pane.tag.own = try p.gpa.dupe(u8, " Put"); + p.update(.{ .file_changed = .{ .pane = .at(id), .bytes = "zero\n" } }); + _ = p.messages.waiting(pane) orelse return error.NotAsked; + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + for (56..161) |cols| { + p.update(.{ .resize = .{ .cols = @intCast(cols), .rows = 30 } }); + p.sync(); + const rest = pardes.layout.wantedTagRows(p, id); + try std.testing.expect(pane.tag_rows <= @max(rest, 1)); + const shown = try pardes.tagline.tagText(p, frame.allocator(), pane); + for ([_][]const u8{ "r Reload", "k Keep mine", "d Diff" }) |word| try std.testing.expect(std.mem.indexOf(u8, shown, word) != null); + _ = frame.reset(.retain_capacity); + } +} + test "a file changed on disk under unsaved text asks in its tag and never takes the keyboard: SPC e's keyboard answers, d shows the disk's lines as ghosts, Esc leaves it waiting, B2 on Reload reads it again" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 }); defer p.deinit(); |
