fix(init): guard read_file_lines against directory paths (#189)

Problem: when a commit contains a submodule or a symlink to a directory,
`read_file_lines` passes the path to `io.open` which succeeds, then
`f:lines()` raises `"Is a directory"` inside the decoration provider.

Solution: check `vim.fn.isdirectory(path)` before `io.open` and return
nil early, which `compute_hunk_context` already handles gracefully.
This commit is contained in:
Barrett Ruth 2026-03-13 07:14:31 -04:00
parent 925ba5cb8a
commit 24a6414d8b
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 36 additions and 0 deletions

View file

@ -347,6 +347,9 @@ end
---@param path string
---@return string[]?
local function read_file_lines(path)
if vim.fn.isdirectory(path) == 1 then
return nil
end
local f = io.open(path, 'r')
if not f then
return nil