I encountered a peculiar bug under a very particular set of circumstances when developing a plugin for Notepad++. After tracking it down, I believe I have identified the problem, confirmed that it is present in the latest version of Scintilla, and I have a potential fix.
Let me start with the reproduction steps:
Expected behavior: No SCN_DWELLEND message.
Actual behavior: An SCN_DWELLEND message is triggered on the next tick.
Detailed explanation that I have found:
The SCI_CALLTIPSETPOSITION message calls InvalidateStyleRedraw. On this next tick this forces a redraw, which eventually invokes ModifyScrollBars. This method attempts to check if the scrollbars need to be updated. For this two values are calculated: horizEndPreferred, which is based on the width of the text; and pageWidth, which is based on the width of the window. If these values differ from nMax and nPage as returned by GetScroll Info, then SetScrollInfo is called using horizEndPreferred is used to set nMax and pageWidth is used to set nPage. However SetScrollInfo clamps nPage to nMax - nMin +1. As a result, when the window is wider than the text the actual new scroll info is not the same as the desired scroll info, and ModifyScrollBars will attempt to set the horizontal scroll info and returns true every time styles are recomputed.
I have attached a patch that I believe should fix this behavior. I have tested it in Notepad++ and found no issues.
OK, committed as [6d6294].
Credited to "Derek". If you prefer a different name in the credits please tell me what you would like.
Related
Commit: [6d6294]
I am already in the credits ("Derek Brown").
On Mon, Oct 18, 2021, 8:48 AM Neil Hodgson nyamatongwe@users.sourceforge.net wrote:
Related
Bugs:
#2288Commit: [6d6294]
I'm actually already in the credits ("Derek Brown").