fix(init): guard read_file_lines against directory paths#190
Merged
barrettruth merged 1 commit intomainfrom Mar 13, 2026
Merged
fix(init): guard read_file_lines against directory paths#190barrettruth merged 1 commit intomainfrom
read_file_lines against directory paths#190barrettruth merged 1 commit intomainfrom
Conversation
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #189.
Problem
When a commit contains a submodule or a symlink to a directory,
read_file_linespasses the path toio.openwhich succeeds on directories, thenf:lines()raises"Is a directory"inside the decoration provider'son_bufcallback.Solution
Add a
vim.fn.isdirectory(path)guard at the top ofread_file_linesininit.luato return nil early.compute_hunk_contextalready handles nil gracefully. Two new tests incontext_spec.luacover both a plain directory and a symlink-to-directory.