Fix caret can disappear from script editor
Fixes #92821 Also probably fixes #92634 but did not find a way to reproduce more than once.
This was not easy to reproduce! To reproduce I did Alt-Tab while resizing the editor windows. And even then, it takes multiple retries to reproduce the problem.
I’m pretty certain that the problem came from a situation where a new SetTimer was called before the timer was actually triggered resulting in a situation where activate_timer_id and move_timer_id had the same timer_id. Both SetTimer for activate_timer_id and move_timer_id had the same nIDEvent, so the second SetTimer replaced the first timer.
Documentation for SetTimer from Microsoft:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-settimer
With some debug print line, we can see that the activate timer can in some situations be created before the resize is triggered:
I did 2 modifications:
- Changed the
nIDEventforactivate_timer_idto 2. - When
WM_ACTIVATEis received butactivate_timer_id != 0, a newSetTimeris created anyway, replacing the first one. That should prevent the weird case whereactivate_timer_idwas never triggered and resetted.