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:
parent
925ba5cb8a
commit
24a6414d8b
2 changed files with 36 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue