Skip to content

Commit

Permalink
fix: validate category of passed in command
Browse files Browse the repository at this point in the history
  • Loading branch information
FeiyouG committed Oct 23, 2022
1 parent 63d1952 commit 69abe85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions lua/command_center/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local function process_commands(items, opts, set_callback, add_callback)
item = utils.convert_item(item, opts)
if not item then goto continue end


-- Register/unregister the keybindings
if item.mode == constants.mode.SET or item.mode == constants.mode.ADD_SET then
if type(set_callback) == "function" then
Expand Down
10 changes: 4 additions & 6 deletions lua/command_center/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ local function validate_item(item)
end
return false
end, "comment_center.mode" },
category = { item.category, "string", true },
cat = { item.cat, "string", true },

hydra_head_args = { item.hydra_head_args, "table", true },
})
Expand Down Expand Up @@ -208,13 +208,13 @@ function M.convert_keys(desc, cmd, keys, opts)
return converted_key
end

function M.set_converted_keys(keys)
function M.set_converted_keys(keys)
for _, key in ipairs(keys) do
vim.keymap.set(key.mode, key.lhs, key.rhs, key.opts)
end
end

function M.del_converted_keys(keys)
function M.del_converted_keys(keys)
for _, key in ipairs(keys) do
vim.keymap.del(key.mode, key.lhs, key.opts)
end
Expand Down Expand Up @@ -256,7 +256,6 @@ function M.format_keys(keys, opts)
return formatted_keys
end


---Generate the string representation of keybindings
---@param keybindings table: properly formatted keybindings (by called format_keybindings)
function M.get_keys_str(keybindings)
Expand Down Expand Up @@ -302,10 +301,9 @@ function M.get_max_width(user_opts, length)
return max_width + 6 -- Leave some margin at the end
end


-- Filter items based on filter
---@return table: filtered item as a list
function M.filter_items(items,filter)
function M.filter_items(items, filter)

local function filter_mode(item, mode)
for _, key in ipairs(item) do
Expand Down
1 change: 1 addition & 0 deletions lua/telescope/_extensions/command_center.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ end
local function run(filter)
filter = filter or {}
local filtered_items, cnt = utils.filter_items(M._items, filter)

local opts = vim.deepcopy(user_opts)

-- Only display what the user specifies
Expand Down

0 comments on commit 69abe85

Please sign in to comment.