kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
2.98k stars 60 forks source link

Weird behaviour with cyrillic characters #168

Closed biozz closed 1 year ago

biozz commented 1 year ago

Checklist

To reproduce

Sample buffer:

this is english
а это русский

Starting from the beginning of the document type: v$S). (visually surround the line)

Then go to the beginning of the next line and do the same.

Expected behavior

I expect the plugin to work the same on both lines and get this:

(this is english)
(а это русский)

Without breaking the encoding.

Actual behavior

Instead I see something like that:

(this is english)
(а это русски<d0>)<b9>

Those <d0> and <b9> are greyed out like control characters.

It also breaks the file encoding. After I open the file again I get:

(this is english)
(а это русскиÐ)¹

And if I do :set fileencoding, it shows latin1 instead of utf8.

Note that I have properly set encoding and fileencoding to utf-8 in my config.

Additional context

No response

kylechui commented 1 year ago

My guess is that this has to do with surrounding multi-byte characters (which I thought I fixed), but I'll look into it when I have the time.

Maybe try using yss to surround the current line instead?

kylechui commented 1 year ago

I'm actually unable to replicate this issue. Can you send me what version of Neovim you're using, as well as if you're using the nightly version of this plugin? In any case, please try updating your plugin to see if it fixes things.

biozz commented 1 year ago
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

Features: +acl +iconv +tui
nvim-surround ❯ git status
HEAD detached at v1.0.0

Thanks for the suggestion about yss, but that defeats the purpose of the plugin for me. I want to be able to visually select stuff before surrounding.

I didn't have this issue with tpope/vim-surround.

kylechui commented 1 year ago

I tried nvim --clean and put in the sample text that you gave, and also tried using the stable release of the plugin. Unfortunately, I was still unable to replicate the issue. If possible, could you also provide a minimal configuration via nvim -u minimal_config.lua that produces the issue?

biozz commented 1 year ago

I think it has to do with one of or a combination of dhruvasagar/vim-table-mode and preservim/vim-markdown. I tried disabling those and it worked. I also enabled them back and it works as well. 🤷‍♂️

Not sure if it needs further investigation. My issue is resolved (for now). Feel free to close the ticket.

Thanks again for the suggestions.

kylechui commented 1 year ago

Yeah I'm not 100% sure what it could be either, if you didn't update your other plugins. Feel free to re-open this issue if the bug pops up again, with a minimal config and steps to reproduce it