Describe the bug
Sometimes after a mouse click VIM goes into VISUAL mode that cannot be canceled anyhow unless clicked again. It takes quite a few clicks to reproduce.
This only happens if popup is visible and while VIM is blocked by external process.
To Reproduce
vim --clean -g \
+'call timer_start(1000, {->system("sleep 1")}, #{repeat: -1})' \
+'call popup_create("hello", {})' \
README.txt
Esc does nothing. Moving mouse changes the selected area.Expected behavior
VIM does not go into eternal mouse pressed state.
Screenshots
https://user-images.githubusercontent.com/717109/120637982-3b016980-c478-11eb-8d2c-ce6959e9d5aa.mp4
Environment
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
I can reproduce it. Looks like the sleep causes some mouse events to go missing and make it look like a double click. That is hard to reproduce and I'm not sure how to fix it.
What I can fix is that when pressing Esc the Visual mode doesn't come back.
That's very unfortunate there is no proper fix. Even though it doesn't reproduce on every click I get struck by this all the time.
You don't actually have a system('sleep 1') call in your code, right?
No I don't have. It is there only to reproduce the bug.
I have a vim script function that apparently runs for long enough to trigger the problem. I will try to split the execution and use timers. Hopefully it helps.
I tried to split and distribute the execution as much as possible but I still struggle with the issue. I don't know what else to try. Splitting it even further will turn my code into an unmaintainable spaghetti mess.
I lowered the sleep time and timer frequency to make it is much easier to reproduce, basically this way it happens almost on every click:
vim --clean -g \
+'call timer_start(100, {->system("sleep 0.1")}, #{repeat: -1})' \
+'call popup_create("hello", {})' \
README.txt
The problem doesn't happen if there are no popups visible.
Wow, I just noticed this received another fix and it totally solved the problem. Bram, thank you so much! 🥳