Skip to content

fix: skip output when stdin is empty#2169

Open
LeonidasZhak wants to merge 1 commit into
dandavison:mainfrom
LeonidasZhak:codex/fix-empty-stdin-ansi
Open

fix: skip output when stdin is empty#2169
LeonidasZhak wants to merge 1 commit into
dandavison:mainfrom
LeonidasZhak:codex/fix-empty-stdin-ansi

Conversation

@LeonidasZhak

Copy link
Copy Markdown

Summary

When delta receives empty stdin (zero bytes), it now produces no output instead of emitting an ANSI reset sequence (\x1b[00;39m).

Problem

printf '' | delta emits a phantom blank line because the painter's output buffer contains an ANSI reset sequence that gets written even when no input is processed.

Solution

Added a has_input flag in StateMachine::consume() that tracks whether any lines were read. If no input was received, return early before the painter emits its output buffer.

Testing

# Before: emits ANSI reset
printf '' | delta | cat -v  # ^[[00;39m

# After: no output
printf '' | delta | cat -v  # (empty)

Fixes #2151

When delta receives empty stdin (zero bytes), it should produce
no output instead of emitting an ANSI reset sequence.

Fixes dandavison#2151
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.

🐛 delta emits ANSI reset on empty stdin, producing a phantom blank line

1 participant