diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 02:56:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 04:13:33 -0300 |
| commit | d1d5d3cfb18841604bba2057eeb3598f729b4475 (patch) | |
| tree | 298c29ab8767852bf74eb86ad4d15acc4348f109 /src/lsp | |
| parent | 33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff) | |
| download | pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip | |
client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/lsp')
| -rw-r--r-- | src/lsp/Ask.zig | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lsp/Ask.zig b/src/lsp/Ask.zig index f071cf7b..8ed0aecc 100644 --- a/src/lsp/Ask.zig +++ b/src/lsp/Ask.zig @@ -264,6 +264,7 @@ fn lspWord(kind: lsp.Kind) []const u8 { } pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { + const v = p.view(); defer pardes.turn.bump(&pardes.turn.lsp_answers); const w = p.lsp_ask.wait orelse return; if (w.id != id) return; // superseded by a newer press, or the pane died @@ -332,7 +333,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { // The one place is the text's places, as a list's would be: tinted, // and n and N step it. const spot = look.parsePathLine(place); - if (!p.look_missed and spot.at.line > 0) if (p.panes[p.active]) |there| if (there.file) |*tf| if (spot.at.line <= panes.File.nlines(p.gpa, tf)) { + if (!p.look_missed and spot.at.line > 0) if (p.panes[v.active]) |there| if (there.file) |*tf| if (spot.at.line <= panes.File.nlines(p.gpa, tf)) { const ls = panes.File.lineStart(p.gpa, tf, spot.at.line - 1); const line = tf.content[ls .. std.mem.indexOfScalarPos(u8, tf.content, ls, '\n') orelse tf.content.len]; const col = @min(spot.at.col -| 1, line.len); @@ -349,7 +350,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { }; if (listing and !p.look_missed) { var where: [300]u8 = undefined; - p.setMessage(p.active, std.fmt.bufPrint(&where, "{s}: the one, {s}", .{ lspWord(w.kind), place[0..@min(place.len, 240)] }) catch lspWord(w.kind)); + p.setMessage(v.active, std.fmt.bufPrint(&where, "{s}: the one, {s}", .{ lspWord(w.kind), place[0..@min(place.len, 240)] }) catch lspWord(w.kind)); } return; } @@ -387,7 +388,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { if (result_pane.serial != p.fs.lsp_result) continue; if (p.next_serial != serial_before) { const report_rows = std.mem.count(u8, result_pane.file.?.content, "\n"); - const wanted: u16 = @intCast(@min(p.screen_h, report_rows + result_pane.tag_rows)); + const wanted: u16 = @intCast(@min(v.screen_h, report_rows + result_pane.tag_rows)); layout.givePaneRows(p, result_id, wanted, w.pane); } look.focusPaneLine(p, result_id, .{ .line = 1, .col = 1 }, .keep); @@ -488,7 +489,7 @@ test "Def and Refs are a speaking file's tag words; gd, gr and a 2-1 chord all r p.update(.{ .key = .{ .cp = 'c' } }); try std.testing.expectEqual(@as(u32, 8), try Asked.one(p, .callstack)); - const r = p.rects[0]; + const r = p.view().rects[0]; const x0 = r.x + config.GUTTER + panes.File.gutterWidth(pane); const use_y = p.bodyTop(pane, r) + 1; // Copied out of the scratch arena, which each p.update resets. @@ -530,7 +531,7 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy p.lspRequest(0, .callstack, ""); const first = p.lsp_ask.wait orelse return error.NoRequest; lspResponse(p, first.id, "╰──┬ /test.txt:1:4-7 work\n@callstack-match ╰─ /test.txt:1:4-7 fn work() {}\n"); - const report = p.panes[p.active].?; + const report = p.panes[p.view().active].?; try std.testing.expect(report != source); try std.testing.expect(std.mem.endsWith(u8, report.file.?.path, "/+Callstack")); try std.testing.expectEqual(@as(i32, 0), source.body.cur_row); @@ -541,22 +542,22 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy defer frame.deinit(); const surface = try p.render(frame.allocator()); p.presented(); - const r = p.rects[p.active]; + const r = p.view().rects[p.view().active]; const row = r.y + report.tag_rows; const col = r.x + config.GUTTER + panes.File.gutterWidth(report) + 7; try std.testing.expectEqual(.off, surface.at(col, row).style.ul); p.update(.{ .mouse = .{ .button = .right, .kind = .press, .row = row, .col = col } }); p.update(.{ .mouse = .{ .button = .right, .kind = .release, .row = row, .col = col } }); try std.testing.expect(!source.collapsed); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expect(!report.body.vsel.active); try std.testing.expectEqual(@as(usize, 0), report.body.nsel); const serial = report.serial; p.lspRequest(0, .callstack, ""); const second = p.lsp_ask.wait orelse return error.NoRequest; lspResponse(p, second.id, "No callers reported\n"); - try std.testing.expectEqual(serial, p.panes[p.active].?.serial); - try std.testing.expectEqualStrings("No callers reported\n", p.panes[p.active].?.file.?.content); + try std.testing.expectEqual(serial, p.panes[p.view().active].?.serial); + try std.testing.expectEqualStrings("No callers reported\n", p.panes[p.view().active].?.file.?.content); } test "Callers with one answer jumps to it and says where, in a msg" { @@ -564,7 +565,7 @@ test "Callers with one answer jumps to it and says where, in a msg" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); const pane = try p.setTestFile("fn a() {}\nfn b() { a(); }\n"); - p.lspRequest(p.active, .incoming_calls, ""); + p.lspRequest(p.view().active, .incoming_calls, ""); const wait = p.lsp_ask.wait.?; p.update(.{ .lsp_resp = .{ .id = wait.id, .rows = "/test.txt:2:10 b\n" } }); try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row); @@ -576,7 +577,7 @@ test "a Rename the language server finds nothing for says so, and changes nothin const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); const pane = try p.setTestFile("const value=1;\n"); - p.lspRequest(p.active, .rename, "renamed"); + p.lspRequest(p.view().active, .rename, "renamed"); const wait = p.lsp_ask.wait.?; p.update(.{ .lsp_resp = .{ .id = wait.id, .rows = "" } }); try std.testing.expectEqualStrings("Rename: nothing here to rename", pane.msg[0..pane.msg_len]); @@ -591,9 +592,9 @@ test "LSP failure clears only its matching wait without completion indentation" pane.body.mode = .insert; pane.body.cur_col = 1; - p.lspRequest(p.active, .completion, ""); + p.lspRequest(p.view().active, .completion, ""); const old_id = p.lsp_ask.wait.?.id; - p.lspRequest(p.active, .completion, ""); + p.lspRequest(p.view().active, .completion, ""); const current_id = p.lsp_ask.wait.?.id; p.update(.{ .lsp_resp = .{ .id = old_id, .rows = null } }); try std.testing.expectEqual(current_id, p.lsp_ask.wait.?.id); @@ -602,7 +603,7 @@ test "LSP failure clears only its matching wait without completion indentation" try std.testing.expectEqualStrings("x", pane.file.?.content); try std.testing.expectEqual(@as(i32, 1), pane.body.cur_col); - p.lspRequest(p.active, .completion, ""); + p.lspRequest(p.view().active, .completion, ""); p.update(.{ .lsp_resp = .{ .id = p.lsp_ask.wait.?.id, .rows = "" } }); try std.testing.expect(p.lsp_ask.wait == null); try std.testing.expectEqualStrings("x ", pane.file.?.content); |
