Menu

#2288 SCN_DWELLEND incorrectly called after SCI_CALLTIPSETPOSITION, SCI_CALLTIPSHOW

Bug
closed-fixed
nobody
5
2021-11-12
2021-10-16
Kered13
No

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:

  1. Size the window so there is no horizontal scrollbar.
  2. Idle the mouse to trigger an SCN_DWELLSTART notification (leave idle for the rest of the steps).
  3. Send SCI_CALLTIPSETPOSITION message.
  4. Send SCI_CALLTIPSHOW message.

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.

1 Attachments

Related

Bugs: #2288

Discussion

  • Neil Hodgson

    Neil Hodgson - 2021-10-18

    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]

    • Kered13

      Kered13 - 2021-10-18

      I am already in the credits ("Derek Brown").

      On Mon, Oct 18, 2021, 8:48 AM Neil Hodgson nyamatongwe@users.sourceforge.net wrote:

      OK, committed as [6d6294].

      Credited to "Derek". If you prefer a different name in the credits please
      tell me what you would like.


      ** [bugs:#2288] SCN_DWELLEND incorrectly called after
      SCI_CALLTIPSETPOSITION, SCI_CALLTIPSHOW**

      Status: open
      Group: Bug
      Created: Sat Oct 16, 2021 10:40 AM UTC by Kered13
      Last Updated: Sat Oct 16, 2021 10:40 AM UTC
      Owner: nobody
      Attachments:

      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:

      1. Size the window so there is no horizontal scrollbar.
      2. Idle the mouse to trigger an SCN_DWELLSTART notification (leave idle
        for the rest of the steps).
      3. Send SCI_CALLTIPSETPOSITION message.
      4. Send SCI_CALLTIPSHOW message.

      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.


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/scintilla/bugs/2288/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       

      Related

      Bugs: #2288
      Commit: [6d6294]

  • Kered13

    Kered13 - 2021-10-18

    I'm actually already in the credits ("Derek Brown").

     
  • Neil Hodgson

    Neil Hodgson - 2021-10-22
    • labels: --> scintilla, win32
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2021-11-12
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.