From cc81a8253be032aa12f05730e8a2f1b5d94fd08c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 16 Feb 2022 16:58:32 +0800 Subject: docs: minor changes related to mapping description --- runtime/doc/api.txt | 2 +- runtime/doc/map.txt | 4 +++- src/nvim/api/vim.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 7a5aeee603..1e1534c31f 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -1584,7 +1584,7 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()* {rhs} Right-hand-side |{rhs}| of the mapping. {opts} Optional parameters map. Accepts all |:map-arguments| as keys excluding || but - including |noremap| and "desc". |desc| can be used + including |noremap| and "desc". "desc" can be used to give a description to keymap. When called from Lua, also accepts a "callback" key that takes a Lua function to call when the mapping is executed. diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 89df42600c..358e944261 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -502,7 +502,9 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which is the start of the last selected Visual area in the current buffer |'<|. The |:filter| command can be used to select what mappings to list. The -pattern is matched against the {lhs}, {rhs} and {desc} in the raw form. +pattern is matched against the {lhs} and {rhs} in the raw form. If a +description was added using |nvim_set_keymap()| or |nvim_buf_set_keymap()| +then the pattern is also matched against it. *:map-verbose* When 'verbose' is non-zero, listing a key map will also display where it was diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index f4909b0801..565015cada 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1584,7 +1584,7 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode) /// @param rhs Right-hand-side |{rhs}| of the mapping. /// @param opts Optional parameters map. Accepts all |:map-arguments| /// as keys excluding || but including |noremap| and "desc". -/// |desc| can be used to give a description to keymap. +/// "desc" can be used to give a description to keymap. /// When called from Lua, also accepts a "callback" key that takes /// a Lua function to call when the mapping is executed. /// Values are Booleans. Unknown key is an error. -- cgit From 758f1e59990ab515c17667f8a4ee2d3fe44af29f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 16 Feb 2022 17:01:35 +0800 Subject: refactor: remove NULL check that is always true --- src/nvim/getchar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 470bf56a6e..6978823f2b 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3583,8 +3583,7 @@ int map_to_exists_mode(const char *const rhs, const int mode, const bool abbr) mp = maphash[hash]; } for (; mp; mp = mp->m_next) { - if ((mp->m_mode & mode) - && mp->m_str != NULL && strstr((char *)mp->m_str, rhs) != NULL) { + if ((mp->m_mode & mode) && strstr((char *)mp->m_str, rhs) != NULL) { return true; } } -- cgit