ibhagwan / fzf-lua

Improved fzf.vim written in lua
GNU Affero General Public License v3.0
2.13k stars 140 forks source link

Bug: When a directory name contains multibyte characters, the shortened path displayed in prompt is wrong. #1355

Closed uga-rosa closed 1 month ago

uga-rosa commented 1 month ago

RTFM Checklist

Operating system

Mac M3

Shell

fish

Neovim version (nvim --version)

0.10.0

Fzf version (fzf --version)

0.52.1 (6432f00)

Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))

--height 50% --reverse

Is the problem reproducible with mini.sh?

Fzf-lua configuration

As is.

require('fzf-lua').setup({})

Describe the bug / steps to reproduce

It seems that if the directory name contains multibyte characters (e.g. これは日本語です), the first character is not taken correctly. Characters are not displayed and the cursor position is off.

image

image

The built-in function pathshorten() handles multibyte characters correctly. If your own pure Lua functions do not handle them well, this is a good choice.

ibhagwan commented 1 month ago

The built-in function pathshorten() handles multibyte characters correctly. If your own pure Lua functions do not handle them well, this is a good choice.

Unfortunately that’s not a good choice, path manipulation happens inside a libuv callback, using vim.fn.pathshorten will result in:

E5560: Vimscript function must not be called in a lua loop callback

I’m sure I can fix it within the path module.

uga-rosa commented 1 month ago

Can vim.schedule help you?

Hope you can solve this problem. There are libraries like this one that may be of some help. https://github.com/uga-rosa/utf8.nvim

ibhagwan commented 1 month ago

Can vim.schedule help you?

Hope you can solve this problem. There are libraries like this one that may be of some help. https://github.com/uga-rosa/utf8.nvim

Wont help for two reasons, (1) can’t use a coroutine in the callback (2) horrible performance (this needs to be called for every entry).

ibhagwan commented 1 month ago

https://github.com/ibhagwan/fzf-lua/commit/57ed2503ce35d7a697d99810797bc12893cd16a6

@uga-rosa, should work as expected now.

uga-rosa commented 1 month ago

Thank you! It's no longer broken.

ibhagwan commented 1 month ago

Thank you! It's no longer broken.

Ty for the update @uga-rosa!