summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 5ca4f34..871d977 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -361,6 +361,30 @@ test("ActionOutcome and DotPayload retain resolved result data", function()
same("problem", domain.ActionOutcome.error(destination, "problem").diagnostic)
end)
+test("Host adapter reads encoding and uses Nvim case conversion", function()
+ local lowered = {}
+ local runtime = {
+ api = {
+ nvim_get_option_value = function(name, options)
+ same("encoding", name)
+ same("global", options.scope)
+ return "utf-8"
+ end,
+ },
+ fn = {
+ tolower = function(value)
+ lowered[#lowered + 1] = value
+ return string.lower(value)
+ end,
+ },
+ }
+ local adapter = host_adapter.new({ runtime = runtime })
+
+ same("utf-8", adapter:read_encoding())
+ same("abc", adapter:lowercase("AbC"))
+ list_same({ "AbC" }, lowered)
+end)
+
test("Host adapter restores exact cursor presentation values", function()
local options = {
guicursor = "n:block,i:ver37-blinkon123",
@@ -7382,6 +7406,38 @@ test("Eager cleanup preserves history and finalizer registrations", function()
same(nil, state.highlight_timer)
end)
+test("Core composition injects host case conversion into matching", function()
+ fresh_sequence_state()
+ local conversions = {}
+ local host = MemoryHost.new({
+ buffer_lines = { "xA" },
+ cursor = { line = 1, byte_column = 1 },
+ lowercase = function(value)
+ conversions[#conversions + 1] = value
+ if value == "a" or value == "A" then
+ return "folded-a"
+ end
+ return value
+ end,
+ input_packets = { { kind = "text", text = "a" } },
+ configuration = {
+ ignore_case = true,
+ mark_cursor = false,
+ mark_char = false,
+ },
+ emit_movement_events = false,
+ })
+
+ local outcome = composition_root.new({ host = host })
+ :invoke_descriptor("f")
+
+ same(domain.ActionKind.MOVEMENT, outcome.kind)
+ same(domain.Position.new(1, 2), outcome.position)
+ truthy(#conversions >= 2)
+ same("a", conversions[1])
+ same("A", conversions[#conversions])
+end)
+
test("Core activation owns the plugin-global sequence state", function()
local state = fresh_sequence_state()
local host = MemoryHost.new()