Skip to content

selected-bg don't work if entry contain ansi escape code #4372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
7 of 10 tasks
phanen opened this issue May 4, 2025 · 3 comments
Closed
7 of 10 tasks

selected-bg don't work if entry contain ansi escape code #4372

phanen opened this issue May 4, 2025 · 3 comments
Labels

Comments

@phanen
Copy link
Contributor

phanen commented May 4, 2025

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.61.3 (d24b58e)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

LS_COLORS= fd --color=always |
 FZF_DEFAULT_OPTS_FILE= FZF_DEFAULT_OPTS= fzf --ansi --multi --color=selected-bg:#ff0000

highlighting seems not correct (but current-bg seems work as expected).
Image

@junegunn
Copy link
Owner

junegunn commented May 4, 2025

Thanks. Can you check if the latest commit on #4370 fixes the problem?

@phanen
Copy link
Contributor Author

phanen commented May 4, 2025

Yes. Can be closed by #4370.

junegunn added a commit that referenced this issue May 4, 2025
junegunn added a commit that referenced this issue May 4, 2025
Test cases:

1. 'jump' should show alternating background colors even when 'alt-bg' is
not defined as before.

  go run main.go --bind load:jump

Two differences:
  * The alternating lines will not be in bold (was a bug)
  * The marker column will not be rendered with alternating background color

2. Use alternating background color when 'alt-bg' is set

  go run main.go --color bg:238,alt-bg:237
  go run main.go --color bg:238,alt-bg:237 --highlight-line

3. 'selected-bg' should take precedence

  go run main.go --color bg:238,alt-bg:237,selected-bg:232 \
                 --highlight-line --multi --bind 'load:select+up+select+up'

4. Should work with text with ANSI colors

  declare -f | perl -0777 -pe 's/^}\n/}\0/gm' |
    bat --plain --language bash --color always |
    go run main.go --read0 --ansi --reverse --multi \
                   --color bg:237,alt-bg:238,current-bg:236 --highlight-line

---

Close #4354
Fix #4372
@junegunn junegunn added the bug label May 4, 2025
junegunn added a commit that referenced this issue May 4, 2025
Test cases:

1. 'jump' should show alternating background colors even when 'alt-bg' is
not defined as before.

  go run main.go --bind load:jump

Two differences:
  * The alternating lines will not be in bold (was a bug)
  * The marker column will not be rendered with alternating background color

2. Use alternating background color when 'alt-bg' is set

  go run main.go --color bg:238,alt-bg:237
  go run main.go --color bg:238,alt-bg:237 --highlight-line

3. 'selected-bg' should take precedence

  go run main.go --color bg:238,alt-bg:237,selected-bg:232 \
                 --highlight-line --multi --bind 'load:select+up+select+up'

4. Should work with text with ANSI colors

  declare -f | perl -0777 -pe 's/^}\n/}\0/gm' |
    bat --plain --language bash --color always |
    go run main.go --read0 --ansi --reverse --multi \
                   --color bg:237,alt-bg:238,current-bg:236 --highlight-line

---

Close #4354
Fix #4372
tmeijn pushed a commit to tmeijn/dotfiles that referenced this issue May 10, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [junegunn/fzf](https://github.com/junegunn/fzf) | minor | `v0.61.3` -> `v0.62.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>junegunn/fzf (junegunn/fzf)</summary>

### [`v0.62.0`](https://github.com/junegunn/fzf/releases/tag/v0.62.0): 0.62.0

[Compare Source](junegunn/fzf@v0.61.3...v0.62.0)

-   Relaxed the `--color` option syntax to allow whitespace-separated entries (in addition to commas), making multi-line definitions easier to write and read
    ```sh
    ```

### seoul256-light

fzf --style full --color='
fg:[#&#8203;616161](https://github.com/junegunn/fzf/issues/616161) fg+:[#&#8203;616161](https://github.com/junegunn/fzf/issues/616161)
bg:#ffffff bg+:#e9e9e9 alt-bg:#f1f1f1
hl:[#&#8203;719872](https://github.com/junegunn/fzf/issues/719872) hl+:[#&#8203;719899](https://github.com/junegunn/fzf/issues/719899)
pointer:#e12672 marker:#e17899
header:[#&#8203;719872](https://github.com/junegunn/fzf/issues/719872)
spinner:[#&#8203;719899](https://github.com/junegunn/fzf/issues/719899) info:[#&#8203;727100](https://github.com/junegunn/fzf/issues/727100)
prompt:#&#8203;0099bd query:[#&#8203;616161](https://github.com/junegunn/fzf/issues/616161)
border:#e1e1e1
'

    - Added `alt-bg` color to create striped lines to visually separate rows
    ```sh
    fzf --color bg:237,alt-bg:238,current-bg:236 --highlight-line

    declare -f | perl -0777 -pe 's/^}\n/}\0/gm' |
      bat --plain --language bash --color always |
      fzf --read0 --ansi --reverse --multi \
          --color bg:237,alt-bg:238,current-bg:236 --highlight-line

-   \[fish] Improvements in CTRL-R binding ([@&#8203;bitraid](https://github.com/bitraid))
    -   You can trigger CTRL-R in the middle of a command to insert the selected item
    -   You can delete history items with SHIFT-DEL
-   Bug fixes and improvements
    -   Fixed unnecessary 100ms delay after `reload` ([#&#8203;4364](junegunn/fzf#4364))
    -   Fixed `selected-bg` not applied to colored items ([#&#8203;4372](junegunn/fzf#4372))

#### Screenshot

<img width="822" alt="image" src="https://github.com/user-attachments/assets/f1dcbdc5-905c-4043-857c-28c75a71d94a" />

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4yIiwidXBkYXRlZEluVmVyIjoiNDAuMTEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants