forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_keymaps.lua
More file actions
79 lines (68 loc) · 2.91 KB
/
Copy pathtest_keymaps.lua
File metadata and controls
79 lines (68 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
local reference_screenshot = MiniTest.expect.reference_screenshot
local child_helper = require("tests.child_helper")
local child = child_helper.new_child_neovim("test_keymaps")
local T = MiniTest.new_set({
hooks = {
pre_once = function() end,
pre_case = function()
child.run_pre_case(true)
child.bo.readonly = false
end,
post_once = child.stop,
},
})
T["keymaps()"] = MiniTest.new_set()
T["keymaps()"]["passthrough Esc - base test setting highlight"] = function()
child.o.lines, child.o.columns = 10, 15
child.lua([[vim.keymap.set("n", "<Esc>", "<cmd>noh<CR>", { desc = "general clear highlights" })]])
child.lua([[
require("copilot.keymaps").register_keymap_with_passthrough("n", "<Esc>", function()
return true
end, "Passthrough Esc", vim.api.nvim_get_current_buf())
]])
child.type_keys("i123", "<Esc>", "o456", "<Esc>")
child.type_keys("/123", "<CR>")
reference_screenshot(child.get_screenshot(), nil, { ignore_text = { 9, 10 }, ignore_attr = { 9, 10 } })
end
T["keymaps()"]["passthrough Esc with func - return false, will remove hl"] = function()
child.o.lines, child.o.columns = 10, 15
child.lua(
[[vim.keymap.set("n", "<Esc>", function() vim.cmd.nohlsearch() end, { desc = "general clear highlights" })]]
)
child.lua([[
require("copilot.keymaps").register_keymap_with_passthrough("n", "<esc>", function()
return false
end, "Passthrough Esc", vim.api.nvim_get_current_buf())
]])
child.type_keys("i123", "<Esc>", "o456", "<Esc>")
child.type_keys("/123", "<CR>")
child.type_keys("<Esc>")
reference_screenshot(child.get_screenshot(), nil, { ignore_text = { 9, 10 }, ignore_attr = { 9, 10 } })
end
T["keymaps()"]["passthrough Esc - return false, will remove hl"] = function()
child.o.lines, child.o.columns = 10, 15
child.lua([[vim.keymap.set("n", "<Esc>", "<cmd>noh<CR>", { desc = "general clear highlights" })]])
child.lua([[
require("copilot.keymaps").register_keymap_with_passthrough("n", "<esc>", function()
return false
end, "Passthrough Esc", vim.api.nvim_get_current_buf())
]])
child.type_keys("i123", "<Esc>", "o456", "<Esc>")
child.type_keys("/123", "<CR>")
child.type_keys("<Esc>")
reference_screenshot(child.get_screenshot(), nil, { ignore_text = { 9, 10 }, ignore_attr = { 9, 10 } })
end
T["keymaps()"]["passthrough Esc - return true, will not remove hl"] = function()
child.o.lines, child.o.columns = 10, 15
child.lua([[vim.keymap.set("n", "<Esc>", "<cmd>noh<CR>", { desc = "general clear highlights" })]])
child.lua([[
require("copilot.keymaps").register_keymap_with_passthrough("n", "<Esc>", function()
return true
end, "Passthrough Esc", vim.api.nvim_get_current_buf())
]])
child.type_keys("i123", "<Esc>", "o456", "<Esc>")
child.type_keys("/123", "<CR>")
child.type_keys("<Esc>")
reference_screenshot(child.get_screenshot(), nil, { ignore_text = { 9, 10 }, ignore_attr = { 9, 10 } })
end
return T