summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index c968d87..69f5087 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -5257,6 +5257,34 @@ test("Acquisition compares first codes with previous-input triggers", function()
same(nil, acquisition_service.match_previous_input_trigger(122, { "xy" }))
end)
+test("Missing previous input preserves cursor and emits exact diagnostic", function()
+ fresh_sequence_state()
+ local origin = domain.Position.new(1, 2)
+ local host = MemoryHost.new({
+ buffer_lines = { "abc" },
+ cursor = origin,
+ configuration = {
+ mark_cursor = false,
+ hide_cursor_on_cmdline = false,
+ repeat_last_char_inputs = { "\r" },
+ },
+ input_packets = { { kind = "text", text = "\r" } },
+ })
+ local service = acquisition_service.new(host)
+
+ local result = service:acquire("f", "n", origin, nil, nil)
+ truthy(result.missing_previous_input)
+ same(nil, result.target)
+ same(origin, host:read_cursor())
+ same(1, #host:diagnostics())
+ same("error", host:diagnostics()[1].level)
+ same("Previous input not found.", host:diagnostics()[1].text)
+ same(
+ acquisition_service.PREVIOUS_INPUT_NOT_FOUND,
+ host:diagnostics()[1].text
+ )
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then