From 0b9df63d1349a9c58cd2c6ab2e43d0d348bd89cb Mon Sep 17 00:00:00 2001 From: rayx Date: Sun, 4 Jul 2021 07:34:38 +1000 Subject: [PATCH] fix: prevent dirname returning '/' if path is empty string --- lua/lspconfig/util.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 89fca86935..c4c21c2264 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -121,7 +121,9 @@ M.path = (function() local strip_dir_pat = path_sep.."([^"..path_sep.."]+)$" local strip_sep_pat = path_sep.."$" dirname = function(path) - if not path then return end + if not path or #path == 0 then + return + end local result = path:gsub(strip_sep_pat, ""):gsub(strip_dir_pat, "") if #result == 0 then return "/"