jbyuki / venn.nvim

Draw ASCII diagrams in Neovim
MIT License
967 stars 21 forks source link

Don't change last visual selection #6

Closed AckslD closed 3 years ago

AckslD commented 3 years ago

It seems venn changes the last visual selection. For example if I select some visual block and do :VBox and then gv then it does not select same same region anymore.

Maybe the last visual selection could be saved before drawing the box and then restored again after?

jbyuki commented 3 years ago

For the moment I don't see a clean way to do this. In order to restore the visual block selection I would need to modify it somehow. I see two ways.

Maybe I'm not seeing something but currently I would rather go the safe way.

jbyuki commented 3 years ago

I will try to see I can merge some PRs into Neovim to make it work that would great.

jbyuki commented 3 years ago

Could you try with the latest commit? I found a way which would not trigger any keymapping and reselect the latest selection with exe "norm! ...".

AckslD commented 3 years ago

Cool, I'll try it. Maybe this it what you did but couldn't you nvim_buf_get_mark() to get the < and > before doing anything and then after set them by putting the cursor there using setpos followed by norm m< and same for >?

AckslD commented 3 years ago

Can confirm that the latest commit indeed works for me :+1:

jbyuki commented 3 years ago

Cool, I'll try it. Maybe this it what you did but couldn't you nvim_buf_get_mark() to get the < and > before doing anything and then after set them by putting the cursor there using setpos followed by norm m< and same for >?

This would work I think, assuming the column is corrected because setpos is byte based and all the multi-bytes characters which venn insert it will shift the column position. This could be another way.