Skip to content

Commit

Permalink
fix(resolve): Check val not nil in resolve funcs (#2097)
Browse files Browse the repository at this point in the history
We did not check `val ~= nil` in the resolve functions, so config like
`{ nil, max = 30 }` will throw a nil error. Also, if the config is `{
padding = _ }`, the logic relies on the function handling the padding is
iterated before the one handling min/max in the map, which is not always
guaranteed.

Fix the bug by adding nil check in the function handling min/max. Close
  • Loading branch information
chmnchiang committed Aug 1, 2022
1 parent 2e05e63 commit 75a5e50
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/telescope/config/resolve.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ end] = function(_, val)
end

_resolve_map[function(val)
return type(val) == "table" and val[1] >= 0 and val[1] < 1 and val["max"] ~= nil
return type(val) == "table" and val["max"] ~= nil and val[1] ~= nil and val[1] >= 0 and val[1] < 1
end] =
function(selector, val)
return function(...)
Expand All @@ -149,7 +149,7 @@ end] =
end

_resolve_map[function(val)
return type(val) == "table" and val[1] >= 0 and val[1] < 1 and val["min"] ~= nil
return type(val) == "table" and val["min"] ~= nil and val[1] ~= nil and val[1] >= 0 and val[1] < 1
end] =
function(selector, val)
return function(...)
Expand Down

0 comments on commit 75a5e50

Please sign in to comment.