ITADN

feat(menu): simplify calculations for selection

#120Pull Requestvdbe 创建于 2024-11-01已合并
V
vdbecommented
When using a negative count for `Menu:select_next` don't go into negative indices instead rollover to the last entry. This simplifies for example the following logic: ```lua local next = function(direction, key) return function() if care.api.is_open() then -- Post PR care.api.select_next(direction) -- Pre PR -- if direction >= 0 then -- care.api.select_next(direction) -- else -- care.api.select_prev(-direction) -- end elseif vim.snippet.active { direction = direction } then vim.snippet.jump(direction) elseif key ~= nil then vim.api.nvim_feedkeys(vim.keycode(key), "n", false) else care.api.complete() end end end vim.keymap.set("i", "<c-n>", next(1)) vim.keymap.set("i", "<c-p>", next(-1)) ```
合并状态:已合并 合并于 2024-11-01 关闭于 2024-11-01 1 条评论