From d1736dcb0665e1d68cf1007c19f7ab0075ef3f0c Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 24 Jan 2023 18:12:31 -0800 Subject: [PATCH] Fix bit math error, explicitly seed random number generator --- lua/guid.lua | 2 +- plugin/guid.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/guid.lua b/lua/guid.lua index 810cd82..1075da2 100644 --- a/lua/guid.lua +++ b/lua/guid.lua @@ -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. diff --git a/plugin/guid.lua b/plugin/guid.lua index a31e99f..8337dba 100644 --- a/plugin/guid.lua +++ b/plugin/guid.lua @@ -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, {})