Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-33231

PgDown should not be able to shift the end of the visible area past the end of the file (when the visible area is smaller than the file)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • Qt Creator 17.0.0
    • Editors
    • None
    • Linux/X11

      When editing a text file that has more lines than the visible area in the editor, we can shift the visible area up and down by using the scrollbar or by pressing the PgUp and PgDown keys. When using the scrollbar, the end line of the visible area can never become greater than the last line of the file, which is the correct behavior and is consistent with other text editors. For example, if the file has 200 lines and the visible area is 50 lines, the scrollbar will not let us shift the end of the visible area past line 200 by not allowing the start of the visible area to shift past line 151.

      However, this is not the case when using the PgDown key. Namely, the end of the visible area is allowed to shift past the end of the file by allowing the start of the visible area to shift to any line, even to the last line of the file. So in the above example where the file has 200 lines and the visible area is 50 lines, pressing the PgDown key while not far from the end of the file can shift the start of the visible area past line 151 and can even end up starting at line 200.

      This can be fixed by making sure that the end of the visible area is never allowed to shift past the end of the file (unless of course the file is smaller than the visible area) regardless of whether we are using the scrollbar or the PgDown key. This check is already being done when using the scrollbar, it just needs to also be done when pressing the PgDown key.

      Steps to reproduce the issue:

      • open a file with 200 or more lines
      • resize the visible text editor area to 50 lines
      • scroll down to the end of the file such that the very last line of the file is not visible
      • click in the middle of the visible area to select a line and press the PgDown key

      What currently happens: the visible area shifts in such a way that only the very last line of the file is visible
      What should happen: the visible area should shift such that the last 50 lines of the file are visible

      Note: the issue can also occur when opening a file. If the editor remembers the line the file was last opened at, it shifts the visible area to show that line. This can also result in only one or a couple of the last lines of the file visible, because there is no check performed that ensures that the end of the visible area doesn't go past the end of the file. As soon as you use the scrollbar or the mouse scroll wheel, the view immediately snaps back to the correct state by placing the end of the visible area at the end of the file, which is pretty jarring.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            davschul David Schulz
            crolix Andy Romanov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes