diff options
Diffstat (limited to 'test/functional/api/keymap_spec.lua')
-rw-r--r-- | test/functional/api/keymap_spec.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index acaccee4e5..2c44905274 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -1465,4 +1465,24 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() eq(1, exec_lua [[return GlobalCount]]) eq('\nNo mapping found', n.exec_capture('nmap <C-I>')) end) + + it('does not overwrite in <unique> mappings', function() + api.nvim_buf_set_keymap(0, 'i', 'lhs', 'rhs', {}) + eq( + 'E227: Mapping already exists for lhs', + pcall_err(api.nvim_buf_set_keymap, 0, 'i', 'lhs', 'rhs', { unique = true }) + ) + + api.nvim_buf_set_keymap(0, 'ia', 'lhs2', 'rhs2', {}) + eq( + 'E226: Abbreviation already exists for lhs2', + pcall_err(api.nvim_buf_set_keymap, 0, 'ia', 'lhs2', 'rhs2', { unique = true }) + ) + + api.nvim_set_keymap('n', 'lhs', 'rhs', {}) + eq( + 'E225: Global mapping already exists for lhs', + pcall_err(api.nvim_buf_set_keymap, 0, 'n', 'lhs', 'rhs', { unique = true }) + ) + end) end) |