Skip to content

Commit

Permalink
fix: ensure path is file before reading
Browse files Browse the repository at this point in the history
  • Loading branch information
willothy committed Jan 5, 2024
1 parent 7e75492 commit 4e4270b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/hawtkeys/ts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ local function find_maps_in_file(filePath)
if not string.match(filePath, "%.lua$") then
return {}
end
local fileContent = Path:new(filePath):read()
local path = Path:new(filePath)
if not path:is_file() then
return {}
end
local fileContent = path:read()
local parser = vim.treesitter.get_string_parser(fileContent, "lua", {}) -- Get the Lua parser
local tree = parser:parse()[1]:root()
local tsKeymaps = {}
Expand Down

0 comments on commit 4e4270b

Please sign in to comment.