summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 01:05:40 -0300
committerGabriel Schneider <[email protected]>2026-11-25 01:26:09 -0300
commite8d772474bfad73dcd6f481b796e86881388117b (patch)
tree4592d478430bec02be0fff6c0d3b9c0358cbb273
parent32f8f603f30a6e6e196da929fa0df82b8e94f4c1 (diff)
downloadpardes-e8d772474bfad73dcd6f481b796e86881388117b.tar.gz
pardes-e8d772474bfad73dcd6f481b796e86881388117b.zip
lsp/Ask: an edit a language server sends (a format `=`, a rename's WorkspaceEdit) holds the reading pane it lands in, as a typed edit does (walk UI M3, found by item 3's golden reading, pick-ui SPEC §6.5 "Editing a reading pane keeps it the same way"): RUN: process-test lsp-client-edit under jumps walk: main.rs formatted by the mock (`=`), then renamed (SPC l r), still showing `Keep` in its tag in every snapshot after the edit (formatted, unformatted, renamed, unrenamed), a reading pane the next jump would step away from its edit; THE CAUSE: Trail.edited (an edit holds the panes showing its file) is called from File.zig's splice for `how == .edit` only, and core/lsp/Ask.zig applyLspEdits puts the server's edits in as the file's new text through File.load (pushUndo, then load: one undo step), which is no `.edit`; THE FIX: applyLspEdits calls Trail.edited after the load (a reload from disk, File.load's other use, still holds nothing); a user hit it: any format or rename by a language server in a pane reading under `Jumps walk`; TEST FIRST: lsp/Ask.zig "an edit a language server sends (a format, a rename) holds the reading pane it lands in, as a typed edit does" (failed before at Ask.zig:790, the pane still reading)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
-rw-r--r--core/lsp/Ask.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/lsp/Ask.zig b/core/lsp/Ask.zig
index 312743d0..b6d32558 100644
--- a/core/lsp/Ask.zig
+++ b/core/lsp/Ask.zig
@@ -244,6 +244,8 @@ fn applyLspEdits(p: *Pardes, pane: *Pane, revision: u32, edits: []const LspEdit)
return false;
};
panes.File.load(p, f, replacement);
+ // An edit asked for, undone as one: a reading pane is held (SPEC §6.5).
+ pardes.Trail.edited(p, f);
const cursor = modal.positionAt(f.content, panes.File.bufferOffset(f, mapped_cursor, false));
pane.body.cur_row = @intCast(cursor.row);
pane.body.cur_col = @intCast(cursor.col);
@@ -777,3 +779,15 @@ test "SPC l r types the new name in the pane's own tag, the body showing each pl
try std.testing.expectEqual(TagState.Kind.rest, s.kind);
try std.testing.expect(p.lsp_ask.wait == null);
}
+
+test "an edit a language server sends (a format, a rename) holds the reading pane it lands in, as a typed edit does (SPEC §6.5)" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 20 });
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ const pane = try p.setTestFile("let x = add(1, 2);\n");
+ try std.testing.expect(pardes.Trail.reading(p, pane));
+ const edits = [_]LspEdit{.{ .start = 8, .end = 11, .text = "sum" }};
+ try std.testing.expect(applyLspEdits(p, pane, pane.file.?.revision, &edits));
+ try std.testing.expectEqualStrings("let x = sum(1, 2);\n", pane.file.?.content);
+ try std.testing.expect(!pardes.Trail.reading(p, pane));
+}