fix(read-file-or-buf): report error when path is a directory (#2213)

This commit is contained in:
Brewinski
2025-06-12 13:26:26 +10:00
committed by GitHub
parent c7edd87820
commit 2030512dfe

View File

@@ -1103,6 +1103,9 @@ function M.read_file_from_buf_or_disk(filepath)
return lines, nil
end
local stat = vim.uv.fs_stat(abs_path)
if stat and stat.type == "directory" then return {}, "Cannot read a directory as file" .. filepath end
-- Fallback: read file from disk
local file, open_err = io.open(abs_path, "r")
if file then