From 75a5e5065376d9103fc4bafc3ae6327304cee6e9 Mon Sep 17 00:00:00 2001 From: chmnchiang Date: Mon, 1 Aug 2022 09:13:06 -0700 Subject: [PATCH] fix(resolve): Check val not nil in resolve funcs (#2097) 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 --- lua/telescope/config/resolve.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/telescope/config/resolve.lua b/lua/telescope/config/resolve.lua index ad8936e..9b951d3 100644 --- a/lua/telescope/config/resolve.lua +++ b/lua/telescope/config/resolve.lua @@ -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(...) @@ -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(...)