[vim/vim] VIM gets stuck in mouse pressed state if popup is visible (#8318)

18 views
Skip to first unread message

Sergey Vlasov

unread,
Jun 3, 2021, 7:31:31 AM6/3/21
to vim/vim, Subscribed

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

  1. Run VIM:
vim --clean -g \
  +'call timer_start(1000, {->system("sleep 1")}, #{repeat: -1})' \
  +'call popup_create("hello", {})' \
  README.txt
  1. Start clicking at different places with at least a second between clicks.
  2. VIM goes to SELECT mode. Pressing Esc does nothing. Moving mouse changes the selected area.
  3. Click again to go unstuck the mouse.

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

  • Vim 8.2.2914
  • OS: Ubuntu 20.04
  • Terminal: GUI


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Jun 3, 2021, 2:32:53 PM6/3/21
to vim/vim, Subscribed

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.

Bram Moolenaar

unread,
Jun 3, 2021, 2:35:42 PM6/3/21
to vim/vim, Subscribed

Closed #8318 via 85eee5b.

Sergey Vlasov

unread,
Jun 3, 2021, 5:21:27 PM6/3/21
to vim/vim, Subscribed

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.

Bram Moolenaar

unread,
Jun 4, 2021, 7:36:36 AM6/4/21
to vim/vim, Subscribed


> 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?
If you call a shell command Vim will be blocked and unresponsive, that
is the cause of the problem. You can try to find another solution for
that.

--
Dogs must have a permit signed by the mayor in order to congregate in groups
of three or more on private property.
[real standing law in Oklahoma, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Sergey Vlasov

unread,
Jun 4, 2021, 1:57:47 PM6/4/21
to vim/vim, Subscribed

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.

Sergey Vlasov

unread,
Jun 8, 2021, 11:14:58 AM6/8/21
to vim/vim, Subscribed

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.

Bram Moolenaar

unread,
Jun 8, 2021, 2:04:10 PM6/8/21
to vim...@googlegroups.com, Sergey Vlasov

Sergey Vlasov wrote:

> 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.

This indeed makes it happen much more often. My assumption that this
was caused by recognizing a double click is wrong. I did some digging,
but it's complicated. The mouse codes don't really support mouse
position change by itself. I'll have to invent a new one.

--
ARTHUR: The swallow may fly south with the sun, or the house martin or the
plover seek warmer hot lands in winter, yet these are not strangers to
our land.
SOLDIER: Are you suggesting coconuts migrate?
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Sergey Vlasov

unread,
Jul 20, 2021, 6:23:27 AM7/20/21
to vim/vim, Subscribed

Wow, I just noticed this received another fix and it totally solved the problem. Bram, thank you so much! 🥳

Reply all
Reply to author
Forward
0 new messages