Ron89 / thesaurus_query.vim

Multi-language Thesaurus Query and Replacement plugin for Vim/NeoVim
http://www.vim.org/scripts/script.php?script_id=5341
Apache License 2.0
220 stars 23 forks source link

Improves cursor position save #37

Closed nickwynja closed 5 years ago

nickwynja commented 5 years ago

Fixes issue where cursor position wouldn't be re-established when using Goyo.

Ron89 commented 5 years ago

Hi @nickwynja , sorry but I don't understand the problem you are trying to resolve. For some reason you added a fake file change on the cursor point only to make an undo point on it? I am not a fan of doing this because it unnecessarily messes the undo tree.

On the other hand, though I didn't look closely at the logic in your code, but your change also makes the plugin printing input prompt 4 times before letting user take action.

nickwynja commented 5 years ago

Hi @Ron89, thanks for taking a look. I haven't seen the multiple prompts you mention but I'll look into it. I'll also try to put together some screen captures to help show the issues I was running into.

nickwynja commented 5 years ago

I've debugged a little further with a minimal config file and I was unable to reproduce the original issues with a simple install of thesaurus_query and Goyo. So it seems like the issues are a problem with my own init.vim config.

This is the first issue I am having:

jan-29-2019 14-37-43

See how after I replace the word, it jumps to the beginning of the paragraph?

My second issue is this:

jan-29-2019 14-44-39

The first issue occurs where the cursor jumps to the beginning of the paragraph and then when I undo, the cursor jumps to a random location.

Again, I was unable to reproduce these with a simple install so it's a strange conflict within my configuration which my patch simply just covered up. I'll close this since it must be a problem on my end.

If you have any guesses what's going on, I'd greatly appreciate it any suggestions.

Ron89 commented 5 years ago

Hi @nickwynja , just a wild guess. You did some script to perform auto-formatting after some events, right? I think the auto-formatting logic is messing with your undo tree and cursor location. It might did something like visual mode the one line above and last line before hitting a empty line, then do gq for the formatting? This could explain the weird undo location.

I can't tell what makes the cursor jump to the top of the paragraph, though. I still think it is still caused by some autocmd triggered event, but I can't tell what it is just by the symptom itself.

nickwynja commented 5 years ago

I've spent some time trying to debug what's going on and just can't figure it out. I'll just use my fork with the patch until I can get to the bottom of it. Thanks for your help!