From c8415f6bb194477fcdd8a9f0c6f8551f1749e6b6 Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 13 Jul 2020 15:18:05 -0400 Subject: lexlua: Return `lexer.colors.name` as a number if possible. --- lexlua/lexer.lua | 5 ++++- test/test_lexlua.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lexlua/lexer.lua b/lexlua/lexer.lua index 0a92f6064..3f24dd79c 100644 --- a/lexlua/lexer.lua +++ b/lexlua/lexer.lua @@ -886,7 +886,10 @@ end -- @name colors -- @class table M.colors = setmetatable({}, { - __index = function(_, name) return M.property['color.' .. name] end, + __index = function(_, name) + local color = M.property['color.' .. name] + return tonumber(color) or color + end, __newindex = function(_, name, color) M.property['color.' .. name] = color end }) diff --git a/test/test_lexlua.lua b/test/test_lexlua.lua index 602f480c7..de047c818 100644 --- a/test/test_lexlua.lua +++ b/test/test_lexlua.lua @@ -1181,7 +1181,7 @@ function test_colors() assert(lexer.colors.red == '') assert(lexer.property['color.red'] == '') lexer.colors.red = 0x0000FF - assert(lexer.colors.red == tostring(0x0000FF)) + assert(lexer.colors.red == 0x0000FF) assert(lexer.property['color.red'] == tostring(0x0000FF)) lexer.colors.blue = '#0000FF' assert(lexer.colors.blue == '#0000FF') -- cgit v1.2.3