summaryrefslogtreecommitdiff
path: root/src/tty.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/tty.zig')
-rw-r--r--src/tty.zig21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/tty.zig b/src/tty.zig
index 818d8b48..6b43acd3 100644
--- a/src/tty.zig
+++ b/src/tty.zig
@@ -232,6 +232,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options) !void {
},
.col = @intCast(m.col),
.row = @intCast(m.row),
+ .ctrl = m.mods.ctrl,
} });
},
.paste => |bytes| {
@@ -417,18 +418,19 @@ fn drainEffects(
.lsp => |q| {
if (!threads_ok) continue; // pre-loop drain: nothing to answer to yet
const pane = core.panes[q.pane] orelse continue;
- const f = pane.file orelse continue;
- // snapshot everything the worker may read (see LspJob)
+ // a pane with no file still asks `status` (it is about the backend,
+ // not the buffer): empty path and source, root from the pane's cwd
+ const f = pane.file;
const job = gpa.create(LspJob) catch continue;
job.* = .{
.id = q.id,
.kind = q.kind,
.offset = q.offset,
- .path = gpa.dupe(u8, f.path) catch {
+ .path = gpa.dupe(u8, if (f) |ff| ff.path else "") catch {
gpa.destroy(job);
continue;
},
- .source = gpa.dupeZ(u8, f.content) catch {
+ .source = gpa.dupeZ(u8, if (f) |ff| ff.content else "") catch {
gpa.free(job.path);
gpa.destroy(job);
continue;
@@ -439,7 +441,7 @@ fn drainEffects(
gpa.destroy(job);
continue;
},
- .root = gpa.dupe(u8, std.fs.path.dirname(f.path) orelse "/") catch {
+ .root = gpa.dupe(u8, if (f) |ff| (std.fs.path.dirname(ff.path) orelse "/") else pane.cwdSlice()) catch {
gpa.free(job.path);
gpa.free(job.source);
gpa.free(job.arg);
@@ -473,8 +475,9 @@ fn lspWorker(gpa: std.mem.Allocator, job: *LspJob, loop: *Loop) anyerror!void {
defer job.free(gpa);
var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit();
- var out: std.ArrayList(u8) = .empty;
- defer out.deinit(gpa);
+ // the shell owns the result buffer; the backend only ever writes to it
+ var out: std.Io.Writer.Allocating = .init(gpa);
+ defer out.deinit();
pardes.lsp.query(gpa, arena.allocator(), .{
.kind = job.kind,
.path = job.path,
@@ -482,8 +485,8 @@ fn lspWorker(gpa: std.mem.Allocator, job: *LspJob, loop: *Loop) anyerror!void {
.offset = job.offset,
.arg = job.arg,
.root = job.root,
- }, &out);
- const rows = gpa.dupe(u8, out.items) catch return;
+ }, &out.writer);
+ const rows = gpa.dupe(u8, out.written()) catch return;
loop.postEvent(.{ .lsp_done = .{ .id = job.id, .rows = rows } }) catch gpa.free(rows);
return;
}