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

issue on rendering (clearning) Chinese characters when switching files on Win-10 #1377

Open
5 tasks done
echaya opened this issue Mar 20, 2022 · 13 comments
Open
5 tasks done
Labels

Comments

@echaya
Copy link

echaya commented Mar 20, 2022

Hi please see the issue in GIF. Essentially when running :Rg command or :Files command (and others), switching from files that contains Chinese characters causes rendering issue that does not clear the Chinese characters from the screen.

chinese display

PS: I've tested on my 2 PCs running Win10Pro and Win10Home, both set CHCP = 65001 and vim, CMD, Powershell, Bash all set the font that supports Chinese. Plz let me know if anything else I could try. Thanks much in advance!

PS2: below is my fzf config, pretty standard I assume.

    "fzf config
    let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.9 } }
    let $FZF_DEFAULT_OPTS="--ansi --preview-window 'right:60%' --margin=1,4"
    let $PATH = "C:\\Program Files\\Git\\usr\\bin;" . $PATH
    "!! note: fd need to be installed separated before using in fd
    "ignored file search is configured @ c:\Users\xxx\AppData\Roaming\fd\ignore
    let $FZF_DEFAULT_COMMAND = 'fd --type f --color always'
    command! -bang -nargs=* Rg
      \ call fzf#vim#grep(
      \   'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(<q-args>), 1,
      \   fzf#vim#with_preview(), <bang>0)
    nnoremap <Leader>/ :Rg<Space>
@junegunn
Copy link
Owner

Can you post a file that I can use to reproduce the problem?

@echaya
Copy link
Author

echaya commented Mar 21, 2022

Here you go:
0_人工智能_70_年,AI_十大里程碑__爱范儿.md

This is how it looks from :Files

Snipaste_2022-03-21_13-06-58

Many thanks in advance!

@echaya
Copy link
Author

echaya commented Mar 25, 2022

Can you post a file that I can use to reproduce the problem?

@junegunn please let me know if you can repro or any further info needed.

@zhuzhzh
Copy link

zhuzhzh commented Jun 3, 2022

I hit this issue as well. I uses Mono fonts.

@cpiger
Copy link

cpiger commented Jun 9, 2022

me too

@lilx2018
Copy link

I modify the code of src\tui\tcell.go, seem it can work:

func (w *TcellWindow) printString(text string, pair ColorPair) {
lx := 0
a := pair.Attr()

style := pair.style()
if a&AttrClear == 0 {
	style = style.
		Reverse(a&Attr(tcell.AttrReverse) != 0).
		Underline(a&Attr(tcell.AttrUnderline) != 0).
		Italic(a&Attr(tcell.AttrItalic) != 0).
		Blink(a&Attr(tcell.AttrBlink) != 0).
		Dim(a&Attr(tcell.AttrDim) != 0)
}

gr := uniseg.NewGraphemes(text)
for gr.Next() {
	rs := gr.Runes()

	if len(rs) == 1 {
		r := rs[0]
		if r < rune(' ') { // ignore control characters
			continue
		} else if r == '\n' {
			w.lastY++
			lx = 0
			continue
		} else if r == '\u000D' { // skip carriage return
			continue
		}

                    // ----------------- Lilx add code start  -------------------------
		n := runewidth.RuneWidth(r)
		var xPos = w.left + w.lastX + lx
		var yPos = w.top + w.lastY
		if xPos < (w.left+w.width) && yPos < (w.top+w.height) {
			// Lilx
			for i := 0; i < n; i++ {
				_screen.SetContent(xPos+i, yPos, r, nil, style)
			}
		}

		lx += n
                    // ----------------- Lilx add code  end-------------------------
	}

            // ----------------- Lilx delete/comment code start  -------------------------
	// var xPos = w.left + w.lastX + lx
	// var yPos = w.top + w.lastY
	// if xPos < (w.left+w.width) && yPos < (w.top+w.height) {
	// 	_screen.SetContent(xPos, yPos, rs[0], rs[1:], style)
	// }
	// lx += runewidth.StringWidth(string(rs))
            // ----------------- Lilx delete/comment code end-------------------------
}

w.lastX += lx

}

@echaya
Copy link
Author

echaya commented Aug 15, 2022

I modify the code of src\tui\tcell.go, seem it can work:

func (w *TcellWindow) printString(text string, pair ColorPair) { lx := 0 a := pair.Attr()

style := pair.style()
if a&AttrClear == 0 {
	style = style.
		Reverse(a&Attr(tcell.AttrReverse) != 0).
		Underline(a&Attr(tcell.AttrUnderline) != 0).
		Italic(a&Attr(tcell.AttrItalic) != 0).
		Blink(a&Attr(tcell.AttrBlink) != 0).
		Dim(a&Attr(tcell.AttrDim) != 0)
}

gr := uniseg.NewGraphemes(text)
for gr.Next() {
	rs := gr.Runes()

	if len(rs) == 1 {
		r := rs[0]
		if r < rune(' ') { // ignore control characters
			continue
		} else if r == '\n' {
			w.lastY++
			lx = 0
			continue
		} else if r == '\u000D' { // skip carriage return
			continue
		}

                    // ----------------- Lilx add code start  -------------------------
		n := runewidth.RuneWidth(r)
		var xPos = w.left + w.lastX + lx
		var yPos = w.top + w.lastY
		if xPos < (w.left+w.width) && yPos < (w.top+w.height) {
			// Lilx
			for i := 0; i < n; i++ {
				_screen.SetContent(xPos+i, yPos, r, nil, style)
			}
		}

		lx += n
                    // ----------------- Lilx add code  end-------------------------
	}

            // ----------------- Lilx delete/comment code start  -------------------------
	// var xPos = w.left + w.lastX + lx
	// var yPos = w.top + w.lastY
	// if xPos < (w.left+w.width) && yPos < (w.top+w.height) {
	// 	_screen.SetContent(xPos, yPos, rs[0], rs[1:], style)
	// }
	// lx += runewidth.StringWidth(string(rs))
            // ----------------- Lilx delete/comment code end-------------------------
}

w.lastX += lx

}

Thank you but have just tested on my side and the issue persists after updateing the func.

@lilx2018
Copy link

@echaya oh, what you mean the content of preview window "causes rendering issue that does not clear the Chinese characters from the screen" ? this is cause by bat.exe, my code can't sovle this problem beacuse bat.exe not change anything, and bat.exe written with "rust" language which I have not knowledge.

on my side, when scroll the candidate window which has Chinese charactors by up/down key , the candidate window also will "causes rendering issue that does not clear the Chinese characters from the screen", after apply my code , it seem the problem solve .

@echaya
Copy link
Author

echaya commented Aug 15, 2022

hey @lilx2018 what console you are using w/ fzf plz? I'm currently only using it within vim.

@lilx2018
Copy link

lilx2018 commented Aug 15, 2022

@echaya I use cmder, nvy (as GUI) + neovim, but I test nvim-qt.exe and goneovim.exe , everyone has same problem, so I think the real reason is of fzf.exe and bat.exe.

What do you mean "what console" ? I use cmder as daily work envirment, but cmd.exe has same problem. On my side, the candidate window "causes rendering issue that does not clear the Chinese characters from the screen" is annoyance, but preview window issue maybe I can ignore.

and my OS is win10 && Win11, amd64.

@tyoul29
Copy link

tyoul29 commented Apr 8, 2023

@echaya I am also experiencing this problem. Is there a solution available now or perhaps a compromise solution?

@tyoul29
Copy link

tyoul29 commented Apr 14, 2023

@echaya I am also experiencing this problem. Is there a solution available now or perhaps a compromise solution?↳

A compromise solution involves downloading vim90rt.zip and gvim90.zip, merging them.

And partially resolving some of the formatting issues, while the left window will no longer have issues of disorder.

The preview window on the right may still contain some Chinese characters that cannot be refreshed. Nonetheless, this approach makes it usable.

@shui-dun
Copy link

shui-dun commented Sep 7, 2023

@echaya I am also experiencing this problem. Is there a solution available now or perhaps a compromise solution?↳

A compromise solution involves downloading vim90rt.zip and gvim90.zip, merging them.

And partially resolving some of the formatting issues, while the left window will no longer have issues of disorder.

The preview window on the right may still contain some Chinese characters that cannot be refreshed. Nonetheless, this approach makes it usable.

Can you tell me how to merge them?

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

7 participants