-
Notifications
You must be signed in to change notification settings - Fork 6
[BUG] error in toggle_format for multi-byte char #124
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When using toggle_format for multi-byte char, only the first byte of the last char will be chosen.
Steps to Reproduce
- Type
这是一段文本. - Visual selection it.
- Type
<leader>mb. 本is split to 3 bytes, and**is add after the first byte.
Expected Behavior
**这是一段文本**
Actual Behavior
Environment
- Neovim version: 0.11.5
- Plugin version: e1eb10b
- OS: Linux
Additional Context
It happened due to utils.get_visual_selection, in which vim.fn.getpos is used to get the end_col. However, it will return the pos of the first byte instead.
In fact, many vim APIs are designed for byte, which could not handle multi-byte char correctly. It is more recommanded to use neovim APIs like nvim_buf_get_mark. But it need huge changes. So a compromise method may be acceptable, to use byteidx to get the last byte of the char.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working