fix(filetype): check for non-nil match in detect.rules (#19129)

This commit is contained in:
Christian Clason 2022-06-27 20:43:37 +02:00 committed by GitHub
parent 0c363d1a70
commit f2fa11708c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -906,9 +906,11 @@ function M.rules(path)
local dir = vim.fn.expand(path, ':h') local dir = vim.fn.expand(path, ':h')
for _, line in ipairs(config_lines) do for _, line in ipairs(config_lines) do
local match = line:match(udev_rules_pattern) local match = line:match(udev_rules_pattern)
local udev_rules = line:gsub(udev_rules_pattern, match, 1) if match then
if dir == udev_rules then local udev_rules = line:gsub(udev_rules_pattern, match, 1)
return 'udevrules' if dir == udev_rules then
return 'udevrules'
end
end end
end end
return 'hog' return 'hog'