-
Notifications
You must be signed in to change notification settings - Fork 321
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
[BUG] Some non-ASCII characters get stuck in the preview pane #1366
Comments
hmm, i cant reproduce this bug. what version of |
@noornee I'm on the latest r30 too, and I use Alacritty as well, though, this doesn't matter as I can reproduce it in other terminal emulators. You can reproduce it by putting these few lines into a file, and making sure to move this file into an empty directory for the bug to be apparent
Then run Weirdly enough, this bug doesn't take place with all emoji characters for example, but with some specific emojis and other non- |
whoaa, i just followed the steps you provided and it reproduced the bug!
ah, true. |
It looks like the issue is coming from the I wrote a very quick program to read in text from standard input and print the widths of each rune: package main
import (
"bufio"
"fmt"
"os"
"github.com/mattn/go-runewidth"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
for _, r := range []rune(scanner.Text()) {
fmt.Printf("%s\t%x\t%d\n", string(r), r, runewidth.RuneWidth(r))
}
}
} I only have basic knowledge of Unicode, but if anyone is able to play around with this, and also cross-reference the results with the table for double width characters (which I believe are scraped from https://unicode.org), that would be much appreciated. |
So I looked into this a bit more and at this point I think the issue is not to do with the I was able to reproduce this kind of issue by writing a simple program that displays user-provided text before clearing it, and inputs like package main
import (
"os"
"time"
"github.com/gdamore/tcell"
"github.com/mattn/go-runewidth"
)
func setText(screen tcell.Screen) {
text := "hello world"
if len(os.Args) > 1 {
text = os.Args[1]
}
x := 0
for _, c := range text {
screen.SetContent(x, 0, c, nil, tcell.StyleDefault)
x += runewidth.RuneWidth(c)
}
}
func main() {
screen, _ := tcell.NewScreen()
screen.Init()
screen.Clear()
setText(screen)
screen.Show()
time.Sleep(time.Second)
screen.Clear()
screen.Show()
time.Sleep(time.Second)
screen.Fini()
} By the way, the documentation for
|
wow, this is interesting!! i suppose we are gonna have to open an issue at |
I would appreciate it if other people confirm this issue as well - just in case it turns out to be an issue specific to my machine. |
I can't claim to have experience with Go, if any at all, but after grabbing the dependencies and running your code with these specific inputs I can confirm that the behavior is exactly as you have described. |
OK I figured it out, actually It turns out that the tables are generated using https://github.com/mattn/go-runewidth/blob/master/script/generate.go and uses https://unicode.org/Public/13.0.0/ucd/EastAsianWidth.txt as the source ( Someone has created a PR to fix this though by updating the version to Unicode 14.0.0: mattn/go-runewidth#56. Although the latest version is now 15.0.0, version 14.0.0 should still fix the issue, at least for these particular set of emojis. Anyway, until that PR gets merged, there's not much more I can do here, since the issue isn't actually to do with the |
It's really interesting the way you were able to narrow down this issue piece by piece until you found the real reason behind it.
Though, it seems that the PR you mentioned has been there forever, and the guys behind go-runewidth for whatever reason aren't willing to merge it yet. Hopefully, they take some action to upgrade their Unicode source soon, for other repos such as this to get resolved. Thank you brother Joe, you've done an amazing job! |
tbh. it's amazing.
ditto! |
Hello,
Thanks for this amazing project. I use LF every day!
I think this bug is related to #807, in which some symbols get stuck in the preview pane when I open a file containing non-ASCII characters or even when previewing it sometimes.
lf-bug.webm
The text was updated successfully, but these errors were encountered: