From 96c494dec345f9a3dd2676048292267552e3f5f8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Jun 2022 21:37:01 +0800 Subject: refactor: correct comments and assertions about mapping rhs (#18821) Also avoid referring to mappings as "keymaps" in commands and docs. *map_empty_rhs* *map-empty-rhs* You can create an empty {rhs} by typing nothing after a single CTRL-V (you have to type CTRL-V two times). Unfortunately, you cannot do this in a vimrc file. --- test/functional/api/keymap_spec.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test/functional') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 4fb2d55a76..4bee10a006 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -321,7 +321,7 @@ describe('nvim_get_keymap', function() eq({space_table}, meths.get_keymap('n')) end) - it('can handle lua keymaps', function() + it('can handle lua mappings', function() eq(0, exec_lua [[ GlobalCount = 0 vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 1 end }) @@ -606,6 +606,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function() eq({''}, curbufmeths.get_lines(0, -1, 0)) eq(generate_mapargs('i', 'lhs', '', {}), get_mapargs('i', 'lhs')) + + -- a single ^V in RHS is also (see :h map-empty-rhs) + meths.set_keymap('i', 'lhs', '\022', {}) + command('normal ilhs') + eq({''}, curbufmeths.get_lines(0, -1, 0)) + eq(generate_mapargs('i', 'lhs', '\022', {}), + get_mapargs('i', 'lhs')) end) it('treats an empty RHS in a mapping like a ', function() @@ -785,7 +792,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end) - it (':map command shows lua keymap correctly', function() + it (':map command shows lua mapping correctly', function() exec_lua [[ vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] @@ -793,7 +800,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() "^\nn asdf ")) end) - it ('mapcheck() returns lua keymap correctly', function() + it ('mapcheck() returns lua mapping correctly', function() exec_lua [[ vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] @@ -801,7 +808,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() "^")) end) - it ('maparg() returns lua keymap correctly', function() + it ('maparg() returns lua mapping correctly', function() exec_lua [[ vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] @@ -895,7 +902,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() eq('\nNo mapping found', helpers.exec_capture('nmap ')) end) - it('can set descriptions on keymaps', function() + it('can set descriptions on mappings', function() meths.set_keymap('n', 'lhs', 'rhs', {desc="map description"}) eq(generate_mapargs('n', 'lhs', 'rhs', {desc="map description"}), get_mapargs('n', 'lhs')) eq("\nn lhs rhs\n map description", -- cgit