• Login
Community
  • Login

Horizontal scrollbar not resizing properly

Scheduled Pinned Locked Moved General Discussion
horizontal scrollbar
11 Posts 5 Posters 340 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.
  • C
    Coises
    last edited by Mar 16, 2025, 1:44 AM

    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
    • M
      mpheath @Frank Paynter
      last edited by Mar 16, 2025, 6:12 AM

      @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
      • G
        guy038
        last edited by guy038 Mar 16, 2025, 9:56 AM Mar 16, 2025, 9:55 AM

        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

        A C 2 Replies Last reply Mar 16, 2025, 10:15 AM Reply Quote 0
        • A
          Alan Kilborn @guy038
          last edited by Alan Kilborn Mar 16, 2025, 10:16 AM Mar 16, 2025, 10:15 AM

          @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
          • G
            guy038
            last edited by Mar 16, 2025, 10:49 AM

            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
            • C
              Coises @guy038
              last edited by Mar 16, 2025, 5:01 PM

              @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
              • G
                guy038
                last edited by guy038 Mar 16, 2025, 6:12 PM Mar 16, 2025, 6:11 PM

                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
                • M
                  mpheath @Frank Paynter
                  last edited by Mar 17, 2025, 12:20 AM

                  @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
                  • G
                    guy038
                    last edited by guy038 Mar 17, 2025, 11:25 AM Mar 17, 2025, 11:19 AM

                    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

                    M 1 Reply Last reply Mar 17, 2025, 12:56 PM Reply Quote 1
                    • M
                      mpheath @guy038
                      last edited by Mar 17, 2025, 12:56 PM

                      @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
                      11 out of 11
                      • First post
                        11/11
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors