From 20fd0091ef4d873fb1ce8b2bbb278664514cac7a Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Thu, 22 Sep 2022 21:23:11 +0530 Subject: Fix: Error when - in hex color | #24 --- lua/colorizer/utils.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lua/colorizer/utils.lua') diff --git a/lua/colorizer/utils.lua b/lua/colorizer/utils.lua index c83c32d..22fa6eb 100644 --- a/lua/colorizer/utils.lua +++ b/lua/colorizer/utils.lua @@ -28,7 +28,6 @@ do -- do not run the loop multiple times local b = string.byte local byte_values = { ["0"] = b "0", ["9"] = b "9", ["a"] = b "a", ["f"] = b "f", ["z"] = b "z" } - local extra_char = { [b "-"] = true } for i = 0, 255 do local v = 0 @@ -45,8 +44,6 @@ do v = bor(v, lshift(1, 2)) v = bor(v, lshift(lowercase - byte_values["a"] + 10, 4)) end - elseif extra_char[i] then - v = i end BYTE_CATEGORY[i] = v end @@ -67,6 +64,13 @@ function utils.byte_is_hex(byte) return band(BYTE_CATEGORY[byte], CATEGORY_HEX) ~= 0 end +---Obvious. +---@param byte number +---@return boolean +function utils.byte_is_valid_colorchar(byte) + return utils.byte_is_alphanumeric(byte) or byte == ("-"):byte() +end + --- Get last modified time of a file ---@param path string: file path ---@return number|nil: modified time -- cgit v1.2.3-70-g09d2