Skip to content

Commit f19cf58

Browse files
alecthomasclaude
andcommitted
fix: do not fail on empty input with --fail
io.ReadFull returns plain io.EOF when zero bytes are read, which the guard treated as fatal, so 0-byte files or stdin printed "chroma: EOF" and exited 1 — breaking the .lessfilter use case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 59a84fd commit f19cf58

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cmd/chroma/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func prepareLenient(r io.Reader, filename string) (string, chroma.Lexer, error)
110110
func prepareSpecific(ctx *kong.Context, r io.Reader, filename string, peekSize, fullSize int) (string, chroma.Lexer) {
111111
data := make([]byte, peekSize)
112112
n, err := io.ReadFull(r, data)
113-
if err != nil && !errors.Is(err, io.ErrUnexpectedEOF) {
113+
if err != nil && !errors.Is(err, io.ErrUnexpectedEOF) && !errors.Is(err, io.EOF) {
114114
ctx.FatalIfErrorf(err)
115115
}
116116

0 commit comments

Comments
 (0)