summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:47:53 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:47:53 +0200
commit3770a731f500e9253bbcf300c213276359a15686 (patch)
tree07cbf7d10bfcdf0d146d2691343e0228ff7389e9 /tests/run.lua
parent768cb71841e9c2b0989d454e6d6804c0f2330eff (diff)
Save command origins
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index f10aa70..938d21a 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -3144,6 +3144,35 @@ test("Motion execution routes non-Visual contexts to the command path", function
end
end)
+test("Command execution saves its origin before destination calculation", function()
+ local host = MemoryHost.new({
+ buffer_lines = { "abc" },
+ cursor = { line = 1, byte_column = 1 },
+ })
+ local view = text_topology.from_host(host)
+ local saved_origin
+ local engine = {
+ calculate = function(_, _, origin)
+ saved_origin = origin
+ host:set_cursor(domain.Position.new(1, 3))
+ return domain.SearchOutcome.boundary_before_any(origin)
+ end,
+ }
+ local executor = motion_executor.new({
+ host = host,
+ destination_engine = engine,
+ })
+ local plan = motion_plan.build(
+ target_plan.build(target("z"), matching_policy()),
+ "f"
+ )
+
+ local outcome = executor:execute(view, "n", plan, 1, true)
+ same(domain.Position.new(1, 1), saved_origin)
+ same(domain.ActionKind.FAILED_SEARCH, outcome.kind)
+ same(domain.Position.new(1, 1), outcome.position)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then