Community
    • Login

    Horizontal scrollbar not resizing properly

    Scheduled Pinned Locked Moved General Discussion
    horizontal scrollbar
    11 Posts 5 Posters 335 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Frank PaynterF
      Frank Paynter
      last edited by

      Notepad++ v8.7.5 (64-bit)
      Build time : Dec 21 2024 - 05:13:03
      Path : C:\Program Files\Notepad++\notepad++.exe
      Command Line : “C:\Users\Frank\Documents\Visual Micro\Micro Logs\Ports\COM4 2025-03-15 20-48-05.inbound.txt”
      Admin mode : OFF
      Local Conf mode : OFF
      Cloud Config : OFF
      Periodic Backup : ON
      Placeholders : OFF
      DirectWrite : ON
      Multi-instance Mode : monoInst
      File Status Auto-Detection : cdEnabledNew (for current file/tab only)
      Dark Mode : OFF
      OS Name : Windows 11 Pro (64-bit)
      OS Version : 24H2
      OS Build : 26100.3476
      Current ANSI codepage : 1252
      Plugins :
      ComparePlugin (2.0.2)
      HexEditor (0.9.12)
      mimeTools (3.1)
      NppConverter (4.6)
      NppExport (0.4)

      I’m looking at the output from a program with ‘wrap’ OFF, and there is quite a bit of ‘trash’ output before the information I want to examine. The ‘trash’ output has some very long lines, and I believe this part sets the initial horizontal scrollbar size. However, when I delete this portion of the output (select all the ‘trash’ material and then DEL), the scrollbar size doesn’t change to reflect the new maximum horizontal extent. As can be seen in the attached screenshot, the horizontal scrollbar is quite small and near the left edge, even though the maximum horizontal extent of the text extends only partway across the screen. With the horizontal scrollbar as it is, I can scroll the text completely off the left side of the screen (and probably all the way into the next state). I have tried resizing the screen in various ways to trigger a refresh, but this does not change the scrollbar size. This looks like a bug to me, but maybe not?

      TIA

      Frank

      d2278d1c-9c96-49ca-8e26-49c8b3572d83-image.png

      mpheathM 2 Replies Last reply Reply Quote 1
      • CoisesC
        Coises
        last edited by

        I can reproduce this.

        An issue for this was opened before and closed with a notation indicating that it won’t be fixed.


        The dismissal of this, and a previous similar issue, seems a bit abrupt to me. It appears that a document never “forgets” the widest it ever was, so long as it remains open in Notepad++. Even cloning the tab to the other view, zooming or changing the font or font size doesn’t cause the width to be reset.

        My guess — I have not investigated — is that this is a Scintilla behavior. (Scintilla is a separate project, with an entirely different author than Notepad++, which does the work of displaying the actual edit window for documents in Notepad++.) If it is, the issue could only be resolved by raising it in the repository for Scintilla; if it isn’t, it seems it should be fixed.

        1 Reply Last reply Reply Quote 2
        • mpheathM
          mpheath @Frank Paynter
          last edited by

          @Frank-Paynter

          #14782
          It is working as designed as I had to remind someone who was going to modify Scintilla sources.

          Notepad++ chooses to use SCI_SETSCROLLWIDTHTRACKING which is documented as never gets smaller. Notepad++ even saves the width to xml file to keep the scrollbar larger between instances.

          Notepad++ could give an option to set a fixed size with disabling SCI_SETSCROLLWIDTHTRACKING and instead use SCI_SETHSCROLLBAR that the user could set.

          Yet blame Scintilla again for some setting that Notepad++ forces on the user in a binary. A report to Scintilla will be closed as it is Notepad++ that needs to change.

          There are plugins like LuaScript, PythonScript, … that can change these settings. So options do exist to users.

          1 Reply Last reply Reply Quote 2
          • guy038G
            guy038
            last edited by guy038

            Hello, @frank-paynter, @coises, @mpheath and All,

            @frank-paynter, if you’re disturbed because the horizontal width of the scroll bar of a document does not reflect the real witdh of that document, simply create a macro, with a shortcut, which does, successively, these two actions :

            • Ctrl + W

            • Ctrl + Shift + T

            Now, at any time, triggering this macro will always set the right width of current document !

            Best Regards,

            guy038

            Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @guy038
              last edited by Alan Kilborn

              @guy038 said:

              triggering this macro will always set the right width of current document !

              While also purging the undo capability for previous changes, resetting the change-history, and eliminating bookmarks and previously-set color styling.

              1 Reply Last reply Reply Quote 2
              • guy038G
                guy038
                last edited by

                Hello, @frank-paynter, @coises, @mpheath, @alan-kilborn and All,

                Oh, my God, Alan, I didn’t think of the lot of side-effects !

                On the other hand, I suppose that, given a very large file, it would get a long time finding the longest line of current file and adjusting, accordingly, the horizontal scroll bar width !

                Best Regards,

                guy038

                1 Reply Last reply Reply Quote 0
                • CoisesC
                  Coises @guy038
                  last edited by

                  @guy038 said in Horizontal scrollbar not resizing properly:

                  Now, at any time, triggering this macro will always set the right width of current document !

                  In addition to the things Alan mentioned — and that it loses your position in the document and reopens it at the top — opening a document only sets the scroll bar to reflect the width of the visible portion of the document. If there is a longer line further down, the scroll bar won’t reflect that width until that line becomes visible. Once it does become visible, the scroll width will never decrease again, even if you delete that line.

                  I was unsure why this happens, but the message above from @mpheath and the link to SCI_SETSCROLLWIDTHTRACKING clarifies it. Scintilla is behaving as designed. In fairness to Notepad++, it chose the least aggravating of the available behaviors. If SCI_SETSCROLLWIDTH_LIKE_ANY_NORMAL_USER_WOULD_EXPECT were an option, I’m sure Notepad++ would have used it.

                  1 Reply Last reply Reply Quote 2
                  • guy038G
                    guy038
                    last edited by guy038

                    Hello, @frank-paynter, @coises, @mpheath, @alan-kilborn and All,

                    Note this comment of @donho , in 2021 :

                    https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9494#issuecomment-777475784

                    I personally don’t care about my method proposed in my initial post. I just thought it could help @frank-paynter, in some way.

                    And I agree with the comment of @sasamner, right above the @donho’s comment !

                    BR

                    guy038

                    1 Reply Last reply Reply Quote 1
                    • mpheathM
                      mpheath @Frank Paynter
                      last edited by

                      @Frank-Paynter

                      Since you have no plugin to run a script in your debug information, LuaScript is a light option to decrease the horizontal scrollbar width. LuaScript can be installed by Plugin Admin.

                      This code can be added to startup.lua by clicking on the menu Plugins -> LuaScript -> Edit Startup Script

                      function OnSwitchFile()
                          -- Set preferred horizontal scrollbar width.
                          local width = 2500
                      
                          if editor.ScrollWidth > width then
                              editor.ScrollWidth = width
                          end
                      end
                      
                      npp.AddEventHandler("OnSwitchFile", OnSwitchFile)
                      

                      and it will decrease the scrollbar width if it exceeds 2500 when the tab is switched. This is a modest number as the code should avoid being too active with changing the existing scrollbar width if it is reasonable. It is the very large scrollbar width shown in the image that needs some decreasing to be manageable.

                      If a very long line is shown again, then the width tracking will increase the scrollbar width. Switching tabs once the long line is not visible can decrease the scrollbar.

                      When Notepad++ is closed, then the number saved to the session.xml file will be 2500 if the scrollbar was recently decreased.

                      1 Reply Last reply Reply Quote 4
                      • guy038G
                        guy038
                        last edited by guy038

                        Hi, @frank-paynter, @coises, @mpheath, @alan-kilborn and All,

                        I gave a try, with my portable v8.7.6 release, of the LuaScript editor.ScrollWith command with value set to 2500.

                        In a new tab, using the simple Lua command editor.ScrollWidth = 2500, while using the default zoom and the Word wrap option off, you can type up to :

                        • 270 characters with the Consolas font, with the default size of 10

                        • 249 characters with the Courier New font, with the defalut size of 10

                        Best Regards,

                        guy038

                        mpheathM 1 Reply Last reply Reply Quote 1
                        • mpheathM
                          mpheath @guy038
                          last edited by

                          @guy038 Good test.

                          The image shows Col: 325 so width of 2500 seems undersized for the OP. If this type of data in the image is regular then probably suggest 4000 though no less than 3500. Too small of a number could cause constant scrollbar jitter when switching tabs as it decreases and increases width.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors