Skip to content

Commit

Permalink
(mini.colors) Fix convert() to have proper Oklab space detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
echasnovski committed Sep 25, 2023
1 parent 5947170 commit ec8cb73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/mini/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ H.infer_color_space = function(x)
local is_num = H.is_number
if is_num(x.l) then
if is_num(x.c) then return 'oklch' end
if is_num(x.a) and is_num(x.a) then return 'oklab' end
if is_num(x.a) and is_num(x.b) then return 'oklab' end
if is_num(x.s) then return 'okhsl' end
end

Expand Down
1 change: 1 addition & 0 deletions tests/test_colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,7 @@ T['convert()']['validates arguments'] = function()
expect.error(function() convert('aaaaaa', 'rgb') end, 'Can not infer color space of "aaaaaa"')
expect.error(function() convert('##aaaaaa', 'rgb') end, 'Can not infer')
expect.error(function() convert({}, 'rgb') end, 'Can not infer color space of {}')
expect.error(function() convert({ l = 50, a = 1 }, 'rgb') end, 'Can not infer color space of')

-- - `nil` is allowed as input
eq(child.lua_get([[MiniColors.convert(nil, 'hex')]]), vim.NIL)
Expand Down

0 comments on commit ec8cb73

Please sign in to comment.