Skip to content

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

Merged
barrettruth merged 1 commit intomainfrom
fix/directory-path-exception
Mar 13, 2026
Merged

fix(init): guard read_file_lines against directory paths#190
barrettruth merged 1 commit intomainfrom
fix/directory-path-exception

Conversation

@barrettruth
Copy link
Owner

Closes #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 on directories, then f:lines() raises "Is a directory" inside the decoration provider's on_buf callback.

Solution

Add a vim.fn.isdirectory(path) guard at the top of read_file_lines in init.lua to return nil early. compute_hunk_context already handles nil gracefully. Two new tests in context_spec.lua cover both a plain directory and a symlink-to-directory.

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.
@barrettruth barrettruth merged commit a1af488 into main Mar 13, 2026
7 checks passed
@barrettruth barrettruth deleted the fix/directory-path-exception branch March 13, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: submodule/directory in a commit causes exception

1 participant