Skip to content

Commit 5dff4f0

Browse files
(mini.clue) Fix handling of 'clipboard' option.
Details: - Resolves #443. Co-authored-by: habeebweeb <[email protected]>
1 parent 246c646 commit 5dff4f0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lua/mini/clue.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,8 +1903,8 @@ end
19031903

19041904
H.get_default_register = function()
19051905
local clipboard = vim.o.clipboard
1906-
if clipboard:find('unnamed') ~= nil then return '*' end
19071906
if clipboard:find('unnamedplus') ~= nil then return '+' end
1907+
if clipboard:find('unnamed') ~= nil then return '*' end
19081908
return '"'
19091909
end
19101910

tests/test_clue.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,39 @@ T['Reproducing keys']['does not register new triggers'] = function()
29372937
validate_trigger_keymap('o', 'i')
29382938
end
29392939

2940+
T['Reproducing keys']["respects 'clipboard'"] = function()
2941+
-- Mock constant clipboard for better reproducibility of system registers
2942+
-- (mostly on CI).
2943+
child.lua([[
2944+
local empty = function() return '' end
2945+
vim.g.clipboard = {
2946+
name = 'myClipboard',
2947+
copy = { ['+'] = empty, ['*'] = empty },
2948+
paste = { ['+'] = empty, ['*'] = empty },
2949+
}
2950+
]])
2951+
2952+
load_module({ triggers = { { mode = 'c', keys = 'g' }, { mode = 'i', keys = 'g' } } })
2953+
validate_trigger_keymap('c', 'g')
2954+
validate_trigger_keymap('i', 'g')
2955+
2956+
local validate_clipboard = function(clipboard_value)
2957+
child.ensure_normal_mode()
2958+
set_lines({})
2959+
2960+
child.o.clipboard = clipboard_value
2961+
2962+
child.ensure_normal_mode()
2963+
type_keys('i', 'g')
2964+
eq(get_lines(), { 'g' })
2965+
end
2966+
2967+
validate_clipboard('unnamed')
2968+
validate_clipboard('unnamedplus')
2969+
validate_clipboard('unnamed,unnamedplus')
2970+
validate_clipboard('unnamedplus,unnamed')
2971+
end
2972+
29402973
T["'mini.nvim' compatibility"] = new_set({
29412974
hooks = {
29422975
pre_case = function()

0 commit comments

Comments
 (0)