neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 88a4ac22f082e5c9d59acd8e9031908e1d2853c3
parent 973e91007ce3f343f7aeed8d30d70a8616ab6bb5
Author: bfredl <bjorn.linse@gmail.com>
Date:   Fri,  1 Apr 2022 10:44:58 +0200

Merge pull request #17946 from lewis6991/fixes

Quick review fixes for autocmds and keymaps
Diffstat:
Mruntime/doc/lua.txt | 2+-
Mruntime/lua/vim/keymap.lua | 6+++---
Msrc/nvim/autocmd.c | 7+++++--
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt @@ -2025,7 +2025,7 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* {rhs} string|function Right-hand side |{rhs}| of the mapping. Can also be a Lua function. If a Lua function and `opts.expr == true`, returning `nil` - or `false` is equivalent to an empty string. + is equivalent to an empty string. {opts} table A table of |:map-arguments| such as "silent". In addition to the options listed in |nvim_set_keymap()|, this table also accepts the diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua @@ -35,8 +35,8 @@ local keymap = {} --- Can also be list of modes to create mapping on multiple modes. ---@param lhs string Left-hand side |{lhs}| of the mapping. ---@param rhs string|function Right-hand side |{rhs}| of the mapping. Can also be a Lua function. ---- If a Lua function and `opts.expr == true`, returning `nil` or `false` ---- is equivalent to an empty string. +--- If a Lua function and `opts.expr == true`, returning `nil` is +--- equivalent to an empty string. -- ---@param opts table A table of |:map-arguments| such as "silent". In addition to the options --- listed in |nvim_set_keymap()|, this table also accepts the following keys: @@ -62,7 +62,7 @@ function keymap.set(mode, lhs, rhs, opts) local user_rhs = rhs rhs = function () local res = user_rhs() - if not res then + if res == nil then -- TODO(lewis6991): Handle this in C? return '' elseif opts.replace_keycodes ~= false then diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c @@ -2353,17 +2353,20 @@ int autocmd_delete_event(int group, event_T event, char_u *pat) bool autocmd_delete_id(int64_t id) { assert(id > 0); + bool success = false; + + // Note that since multiple AutoCmd objects can have the same ID, we need to do a full scan. FOR_ALL_AUEVENTS(event) { FOR_ALL_AUPATS_IN_EVENT(event, ap) { for (AutoCmd *ac = ap->cmds; ac != NULL; ac = ac->next) { if (ac->id == id) { aucmd_del(ac); - return true; + success = true; } } } } - return false; + return success; } // ===========================================================================