summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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));
+}