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

fix: wrong last_pos in visual mode when vim.o.selection='exclusive' #158

Closed adoyle-h closed 1 year ago

adoyle-h commented 1 year ago

When vim.o.selection='exclusive', last character will be not included in selection. nvim-surround should keep same behavior.

kylechui commented 1 year ago

This is interesting; does vim.o.selection not change how the visual selection marks are set? A few more points:

In general though, thanks for taking the time to make a PR!

adoyle-h commented 1 year ago

@kylechui

does vim.o.selection not change how the visual selection marks are set?

It doesn't change the selection marks. Just the last character of a line is not included. You can see :h selection. The default value is inclusive.

Why vim.o as opposed to vim.opt?

Does this issue appear when using the other visual modes? e.g. visual block mode

I have tried this commit. Only regular visual mode has this issue. Visual line mode and Visual block mode both work well.

kylechui commented 1 year ago

Does it work with multibyte chars?

adoyle-h commented 1 year ago

Does it work with multibyte chars?

I see that multibyte chars test cases in https://github.com/kylechui/nvim-surround/blob/main/tests/basics_spec.lua#L398 . But it runs failed even in master branch. So I tried these multibyte texts and emoji manually, all work.

kylechui commented 1 year ago

The style check is failing, I think probably because you changed the indentation size to 2? Please use indent size 4 + spaces instead of tabs, and I'll merge this in.

kylechui commented 1 year ago

Thanks for taking the time to contribute! I really appreciate it