summaryrefslogtreecommitdiff
path: root/core/Effect.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Effect.zig')
-rw-r--r--core/Effect.zig25
1 files changed, 18 insertions, 7 deletions
diff --git a/core/Effect.zig b/core/Effect.zig
index 3bca04c9..6146df69 100644
--- a/core/Effect.zig
+++ b/core/Effect.zig
@@ -64,6 +64,10 @@ pub const Effect = union(enum) {
/// `arg` up to 128 bytes, or for `explain` the query it explains,
/// `<kind> <arg>`.
lsp: struct { id: u32, kind: lsp.Kind, pane: Pane.Id, offset: u32, arg: Buf(160) },
+ /// A file opened in pane `pane` (File.open, a session's revived pane):
+ /// the server its language speaks to started and told of it, off the
+ /// loop (dev/Lsp.zig open), so its first query finds it ready.
+ lsp_open: struct { pane: Pane.Id },
/// Snapshot the matching request with pipeRequest(id), then run it away
/// from the UI/event loop and answer with pipe_resp.
pipe: struct { id: u32 },
@@ -216,6 +220,8 @@ fn performInner(p: *Pardes, e: Effect) void {
},
.lsp => |q| p.tape.host(p, .lsp, .{.{ .id = q.id, .kind = q.kind, .pane = q.pane, .offset = q.offset, .arg = q.arg.slice() }}) orelse
p.update(.{ .lsp_resp = .{ .id = q.id, .rows = "" } }),
+ // No workers here (a test, a board): no server starts before a query.
+ .lsp_open => |o| _ = p.tape.host(p, .lsp_open, .{o.pane}),
.pipe => |q| p.tape.host(p, .pipe, .{q.id}) orelse
p.update(.{ .pipe_resp = .{ .id = q.id, .success = false, .outputs = &.{} } }),
// No workers here (a test, a board): it runs on the loop.
@@ -442,8 +448,9 @@ test "Save on an output buffer writes its rows out and leaves the buffer alone"
const rows = try gpa.dupe(u8, out.file.?.content);
defer gpa.free(rows);
- // Save leads its tagline now, and the path is REQUIRED: a bare Save asks
- try std.testing.expectEqualStrings(tagline.file_pane_tail, tagline.curTail(out));
+ // Save is one of its words (`:`'s, UX K'4), and the path is REQUIRED: a
+ // bare Save asks
+ try std.testing.expectEqualStrings(tagline.file_pane_tail, tagline.kindTail(out));
try std.testing.expect(p.executeBuiltinLine(id, "Save"));
try std.testing.expect(out.prompt == .save);
try edit.insertKey(p.editor(), &out.input, .{ .cp = 'h', .text = "help.txt" });
@@ -626,25 +633,29 @@ test "a save whose pane is gone before the drain writes nothing" {
try std.testing.expect(p.fallback.get("/tmp/pardes-gone/recycled.txt") == null);
}
-test "Save reaches every tagline with text behind it and no other" {
+test "Save is a word of every pane with text behind it and no other" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
while (p.nextEffect()) |_| {}
+ // Its kind's words (what `:` lists, UX K'4); its tag's, while clean,
+ // Del alone (K'3).
const out = try p.setTestFile("build.zig:1:1 pub fn main\n");
out.file.?.output = .{ .from = .search };
- try std.testing.expectEqualStrings(tagline.locations_pane_tail, tagline.curTail(out));
+ try std.testing.expectEqualStrings(tagline.locations_pane_tail, tagline.kindTail(out));
+ try std.testing.expectEqualStrings(" Del", tagline.computedWords(out));
- // A scratch is an output buffer that wears the FILE tails.
+ // A scratch is an output buffer that has the FILE words.
out.file.?.output = .{ .from = .{ .cmd = std.meta.stringToEnum(pardes.Builtin, "New").? } };
- try std.testing.expectEqualStrings(" Save Term Collapse Follow Del", tagline.curTail(out));
+ try std.testing.expectEqualStrings(" Save Term Collapse Follow Del", tagline.kindTail(out));
// An image's bytes on disk already are what they are: nothing of the
// pane's own is unwritten, so the word is absent and inert.
const img_id = p.freeSlot().?;
const img = try pardes.Kind.open(p, img_id, pardes.Kind.test_kind.of(p), "/tmp/pardes-tag.ppm", "");
- try std.testing.expectEqualStrings(" Term Collapse Del", tagline.curTail(img));
+ try std.testing.expectEqualStrings(" Del", tagline.kindTail(img));
+ try std.testing.expectEqualStrings(" Del", tagline.computedWords(img));
try std.testing.expect(p.executeBuiltinLine(img_id, "Save"));
try std.testing.expect(img.prompt != .save);
var buf: [256]u8 = undefined;