Skip to content

Commit b359e38

Browse files
alecthomasclaude
andcommitted
fix: honour --check when reading from stdin
The stdin path formatted unconditionally; only the file loop consulted --check. Piped input now runs the tokenisation check, reporting as "-" when no --filename is given. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent f19cf58 commit b359e38

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cmd/chroma/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ func main() {
230230
if len(cli.Files) == 0 {
231231
var contents string
232232
var lexer chroma.Lexer
233+
if cli.Check {
234+
contents, lexer, err = prepareLenient(os.Stdin, cli.Filename)
235+
ctx.FatalIfErrorf(err)
236+
name := cli.Filename
237+
if name == "" {
238+
name = "-"
239+
}
240+
check(name, lex(ctx, lexer, contents))
241+
return
242+
}
233243
if cli.Fail {
234244
contents, lexer = prepareSpecific(ctx, os.Stdin, cli.Filename, 1024, -1)
235245
} else {

0 commit comments

Comments
 (0)