diff --git a/tests/specs/dot-repeat_spec.lua b/tests/specs/dot-repeat_spec.lua index e4d1fb0..1c5532f 100644 --- a/tests/specs/dot-repeat_spec.lua +++ b/tests/specs/dot-repeat_spec.lua @@ -15,7 +15,7 @@ describe("dot `.` repeat", function() assert.buffer("a a w a w a w end") end) - it("should preserve option after another hop", function() + it("should preserve options after another hop", function() h.feedkeys("d", false) h.hop_with_character(ft.hop_forward_to_char, "w") assert.buffer("a a w a w a w a w end") @@ -26,7 +26,7 @@ describe("dot `.` repeat", function() assert.buffer("a a w a w a w end") end) - it("should preserve option after user repeat", function() + it("should preserve options after user repeat", function() h.feedkeys("d", false) h.hop_with_character(ft.hop_forward_to_char, "w") assert.buffer("a a w a w a w a w end") @@ -64,4 +64,39 @@ describe("dot `.` repeat", function() h.feedkeys(".", true) assert.buffer("a | a end") end) + + it("should work with custom-operators", function() + vim.keymap.set("n", "f", ft.hop_forward_to_char) + + local start_column = nil + local end_column = nil + local update_operator_area = function() + start_column = vim.api.nvim_buf_get_mark(0, "[")[2] + 1 + end_column = vim.api.nvim_buf_get_mark(0, "]")[2] + 1 + end + + -- selene: allow(global_usage) + _G.Test_operator = update_operator_area + vim.opt.operatorfunc = "v:lua.Test_operator" + + vim.api.nvim_feedkeys("g@fw", "nx", false) + assert.are.same(3, start_column) + assert.are.same(7, end_column) + + h.set_cursor(1, 7) + vim.api.nvim_feedkeys(".", "nx", false) + assert.are.same(7, start_column) + assert.are.same(11, end_column) + end) + + it("should work in macros that uses dot", function() + vim.keymap.set("n", "f", ft.hop_forward_to_char) + + vim.api.nvim_feedkeys("dwu", "ntx", true) + vim.fn.setreg("a", ".fw") + + vim.api.nvim_feedkeys("@a", "nx", true) + assert.buffer("a a w a w a w a w a w end") + assert.cursor_at(1, 5) + end) end)