Skip to content

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

@HaleTom

Description

@HaleTom

When delta receives empty stdin (zero bytes), it emits \x1b[00;39m (ANSI reset + default foreground color), which renders as a visible blank line in the terminal.

Reproducer

# Terminal: phantom blank line appears
printf '' | delta

# Proof it's an ANSI escape, not a newline
printf '' | delta | cat -v
# ^[[00;39m

# Byte count confirms it's the escape sequence, not a newline
printf '' | delta | wc -c
# 10

# Expected: no output at all (like cat)
printf '' | cat
# (no output)

Contrast with 2-arg mode

2-arg mode with empty files produces clean output (no extra line):

delta /dev/null /dev/null
# (no output)

Impact

When delta is used as a diff colorizer in a pipeline, any upstream command that produces only stderr (no stdout) feeds empty stdin to delta. The resulting ANSI reset renders as a phantom blank line between the error message and the next prompt.

Example — diff invoked with no file arguments:

diff /dev/null 2>/dev/null | delta  # prints a blank line

Expected behavior

When stdin is empty (zero bytes), delta should produce no output — same as cat on empty stdin.

  • Please include the raw text output from git, so that we can reproduce the problem.
    (You can use git --no-pager to produce the raw text output.)
    Not a git diff issue — this reproduces with printf '' | delta and no git involved.
  • A screenshot of Delta's output is often helpful also.
    The output is a single blank line — a screenshot wouldn't add information beyond cat -v above.

Environment

  • delta version: 0.19.2
  • OS: Manjaro Linux (kernel 7.0.3-1, x86_64)
  • Terminal: kitty 0.42.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions