Fix bit math error, explicitly seed random number generator

This commit is contained in:
Alex Yatskov 2023-01-24 18:12:31 -08:00
parent 202095edad
commit d1736dcb06
2 changed files with 3 additions and 1 deletions

View File

@ -69,7 +69,7 @@ local function guid_generate()
-- Set the two most significant bits (bits 6 and 7) of the
-- clock_seq_hi_and_reserved to zero and one, respectively.
bytes[9] = bit.band(bit.bor(bytes[9], 0x80), 0x8f)
bytes[9] = bit.band(bit.bor(bytes[9], 0x80), 0xbf)
-- Set the four most significant bits (bits 12 through 15) of the
-- time_hi_and_version field to the 4-bit version number.

View File

@ -18,6 +18,8 @@ if not vim.g.guid then
guid.guid_object()
end
math.randomseed(os.time())
vim.api.nvim_create_user_command('GuidFormat', format, {nargs = '?'})
vim.api.nvim_create_user_command('GuidInsert', insert, {nargs = '?'})
vim.api.nvim_create_user_command('GuidObject', object, {})