Skip to content
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

Lines not flushed correctly in presence of emoji #2482

Closed
5 of 10 tasks
y0ast opened this issue May 11, 2021 · 2 comments
Closed
5 of 10 tasks

Lines not flushed correctly in presence of emoji #2482

y0ast opened this issue May 11, 2021 · 2 comments
Labels

Comments

@y0ast
Copy link

y0ast commented May 11, 2021

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Relevant:
#1526
#2163

But different enough for its own issue.

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

curl https://raw.githubusercontent.com/LukeSmithxyz/voidrice/master/.local/share/larbs/emoji | fzf

Search for something, then remove a character and see spurious ; and other characters appear on lines. ctrl+L fixes it.

core problem is this:


import (
	"fmt"

	"github.com/mattn/go-runewidth"
)

func main() {
	fmt.Println(runewidth.StringWidth("☺️"))
	fmt.Println(runewidth.RuneWidth('☺')) // created from above but deleting the modifier
	fmt.Println(runewidth.RuneWidth('️')) // created from first line, but backspacing the emoji char leaving the modifier
}
$ go run main.go
1
1
1

Fzf computes width of line using runewidth.Runewidth instead of runewidth.StringWidth. The second takes into account zero width emoji modifiers:

RuneWidth of just emoji = 1, RuneWidth of the modier= 1, so fzf thinks length is 2
However StringWidth of emoji+modifier = 1 (which is correct)

When computing number of spaces to pad with, fzf misses 1 (or more) and random characters appear.

@junegunn junegunn added the bug label May 12, 2021
@junegunn
Copy link
Owner

Thanks for the repro and the suggested fix. I'll look into it when I get some time.

@y0ast
Copy link
Author

y0ast commented May 14, 2021

Fix works! Thanks a lot :)

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