Skip to content

Commit 2ae1818

Browse files
authored
fix(filetype.lua): don't fail on empty filepath (#465)
1 parent 9a0d3bf commit 2ae1818

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

lua/plenary/filetype.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ filetype.detect_from_extension = function(filepath)
119119
end
120120

121121
filetype.detect_from_name = function(filepath)
122-
filepath = filepath:lower()
123-
local split_path = vim.split(filepath, os_sep, true)
124-
local fname = split_path[#split_path]
125-
local match = filetype_table.file_name[fname]
126-
if match then
127-
return match
122+
if filepath then
123+
filepath = filepath:lower()
124+
local split_path = vim.split(filepath, os_sep, true)
125+
local fname = split_path[#split_path]
126+
local match = filetype_table.file_name[fname]
127+
if match then
128+
return match
129+
end
128130
end
129131
return ""
130132
end

0 commit comments

Comments
 (0)