fzf.vim
fzf.vim copied to clipboard
issue on rendering (clearning) Chinese characters when switching files on Win-10
- [x] I have fzf 0.23.0 or above
- [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [x] I have read through the manual page of fzf (
man fzf
) - [x] I have searched through the existing issues
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.
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>
Can you post a file that I can use to reproduce the problem?
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.
I hit this issue as well. I uses Mono fonts.
me too
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
}
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.
@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 .
hey @lilx2018 what console you are using w/ fzf plz? I'm currently only using it within vim.
@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.
@echaya I am also experiencing this problem. Is there a solution available now or perhaps a compromise solution?
@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.
@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?