Skip to content

Commit 6124d13

Browse files
committed
add error checks
1 parent aa1e1ec commit 6124d13

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/nvim-tree/utils.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,18 @@ end
7272

7373
--- Path normalizations for windows only
7474
local function win_norm_path(path)
75+
if path == nil then
76+
return path
77+
end
7578
local norm_path = path
7679
-- Normalize for issue #2862 and #2961
7780
if has_parentheses_and_brackets(norm_path) then
7881
norm_path = norm_path:gsub("/", "\\")
7982
end
8083
-- Normalize the drive letter
81-
norm_path = string.upper(string.sub(norm_path, 1, 1)) .. string.sub(norm_path, 2)
84+
norm_path = norm_path:gsub("^%l:", function(drive)
85+
return drive:upper()
86+
end)
8287
return norm_path
8388
end
8489

0 commit comments

Comments
 (0)