From 179162abe0c626ed8f1fc477c15c5cef73654dd4 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Sat, 11 Jun 2022 02:16:38 -0700 Subject: [PATCH] fix(path_shorten): validate non-zero positive number --- lua/fzf-lua/path.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/fzf-lua/path.lua b/lua/fzf-lua/path.lua index 8b39fc9..1b2e2fd 100644 --- a/lua/fzf-lua/path.lua +++ b/lua/fzf-lua/path.lua @@ -137,7 +137,7 @@ function M.shorten(path, max_len) local sep = M.separator() local parts = {} local start_idx = 1 - max_len = max_len or 1 + max_len = max_len and tonumber(max_len)>0 and max_len or 1 repeat local i = find_next(path, sep, start_idx) local end_idx = i and start_idx+math.min(i-start_idx, max_len)-1 or nil