Skip to content

Commit

Permalink
Fixes: kndndrj#92
Browse files Browse the repository at this point in the history
  • Loading branch information
JustBarnt committed Mar 6, 2024
1 parent 2f8e14e commit c6f3d99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/dbee/ui/drawer/convert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function M.help_node(mappings)
table.insert(
children,
NuiTree.Node {
id = "__help_action_" .. tostring(os.clock()),
id = "__help_action_" .. utils.generate_guid(7),
name = km.action .. " = " .. km.key .. " (" .. km.mode .. ")",
type = "",
}
Expand Down
14 changes: 14 additions & 0 deletions lua/dbee/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,18 @@ function M.create_singleton_autocmd(events, opts)
vim.api.nvim_create_autocmd(events, opts)
end

-- Creates a GUID based of the character length passed
---@param length integer length of the GUID generated
---@return string A generated guid
function M.generate_guid(length)
local template = string.rep('x', length)

local guid = string.gsub(template, 'x', function()
local v = math.random(0,15)
return string.format('%x', v)
end)

return guid
end

return M

0 comments on commit c6f3d99

Please sign in to comment.