From e8d772474bfad73dcd6f481b796e86881388117b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 01:05:40 -0300 Subject: 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) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/lsp/Ask.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core') 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)); +} -- cgit v1.3