Horizontal scrollbar appears in script editor when it shouldn't

A horizontal scrollbar can appear in the script editor, even when it shouldn’t be there, and this happens particularly when viewing long scripts. This is what it should look like, with line 1047 being the end of the script:

But sometimes, a scrollbar appears, even though the horizontal space in the editor is not actually limited:

Some observations:

  • Scrolling to the end of the script (sometimes) makes the scrollbar disappear.
  • Using up the available horizontal space of the editor (eg. doing something like pasting a long string of “aaaaa” and then deleting it) makes the scrollbar disappear.
  • Going into testing mode and then exiting makes the scrollbar reappear.
  • Switching from one script to another does not make the scrollbar reappear, unless you close the editor completely for the script that previously had the horizontal scrollbar visible. Then it reappears.