Skip to content

Wrong placement of ‘ANSI colour off’ with --no-hscroll when the string contains zero-width characters #4620

@vejkse

Description

@vejkse

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.67.0 (2ab923f)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Run

for i in {1..200}; do string+=''; printf '\e[43m%s\e[0m\n' "$string"; done | FZF_DEFAULT_OPTS= fzf --ansi --no-hscroll

where each line is some number of times the character a followed by the zero-width COMBINING MACRON BELOW (U+0331), with yellow background colour, or

for i in {1..200}; do string+=$'a\1'; printf '\e[43m%s\e[0m\n' "$string"; done | FZF_DEFAULT_OPTS= fzf --ansi --no-hscroll

where each line is some number of times the character a followed by the control character \1 (which I often use as a --delimiter).

In both cases, the background colour covers the whole line when it is shorter than the available width. But for longer lines, the background colour covers only about the half of the line. It looks like the ANSI colour code ‘off’ is placed after N characters (of any width), where N is the number of available columns, rather than after N cells.

In both examples above, without --no-hscroll, all lines are fully coloured. (There is still a problem, not much related to colour in the case, where the last character of a line stays in place when scrolling — this may be an instance of #1526.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions