Skip to content

Moving the cursor up at end of file with wrapped lines in file scrolls the buffer up also, as many times as wrapped lines exist #1147

@dragonfyre13

Description

@dragonfyre13

Based on testing, my best guess is it appears there's an issue with how it's calculating where the end of the file is for the purposes of moving the cursor around and where to scroll the buffer. It appears in multiple areas to believe the file is X lines long, where X is the number of unwrapped lines, rather than including the number of additional lines that wrapping adds to this. The issue(s) make navigating a file with wrapped lines difficult and alter behavior very unexpectedly for the user.

Seemingly associated issues with the same root cause (included in reproduction steps):

  • Moving the cursor up from the bottom of a file that contains wrapped lines scrolls the buffer up, leaving the cursor on the bottom line of the buffer (even though more content remains in the file below the cursor)
  • When the final line in a file wraps, you're unable to move to the next wrapped line by using any "go to end of line" shortcut (e.g. end, shift+end, etc.), or navigate to the next line in wrapped text by pressing "down".
  • When past the number of "unwrapped lines" in the file, pressing down to go to the next wrapped line goes instead to the start of the next line (in a line position where it would if no wrapping existed).

Reproduction of all associated issues:

  • Size your terminal (via splits or otherwise) to be 25 lines high.
  • Create a file that has 20 lines in it that do not wrap at the current terminal width, 3 lines that wrap once at the current terminal width, 3 lines that wrap twice at current terminal width. Do not include a final newline.
  • Press "Ctrl+Home" to move to the start of file. Then, press "down" 21 times so the cursor is located on the 2nd wrapped line of what the gutter shows is line 21. Press "down" once more, showing the buffer properly moves down to leave several lines of context below the cursor. -- This is correct behavior
  • Press "down" 3 times. Notice that while the cursor moves down each time, the buffer does not shift its range. -- This is incorrect, since the file has additional context below the current buffer range it should shift the buffer down one line as well.
  • Move to the bottom of the file with your cursor on the last character (Ctrl+End). The buffer will range from the start of line 11 to the 3rd line (the last wrapped line) in what the gutter shows is line 26. -- This is correct behavior.
  • Press the "up" key.
  • The buffer will immediately scroll up (it shouldn't), keeping your cursor on the bottom line of the buffer. The buffer will range from line 10 to the wrapped 2nd line in what the gutter shows is line 26. -- This is incorrect behavior, it should not scroll up.
  • Press "up" 8 more times. Each time, it will scroll the buffer up immediately, keeping your cursor on the last (wrapped) line of the buffer. The buffer will now range from line 2 to the wrapped 2nd line of what the gutter shows is line 23. -- This is incorrect behavior as well, it should not scroll up with the cursor remaining at the bottom of the buffer. The cursor should move up without the buffer scrolling.)
  • Press up once more. The cursor is no longer at the bottom of the buffer, instead is on the first wrapped line of line 23 while the buffer remains ranging from line 2 to the 2nd wrapped line of line 23. -- This is correct behavior.
  • Press the "down" key. The cursor moves to the last line of the buffers current range (the 2nd wrapped line of what the gutter shows is line 23), while the buffers current range does not change. -- This is incorrect, it should shift the buffer down when the cursor is within a few lines of the end rather than letting the cursor reach the end line of the buffer
  • Press the "down" key again. The cursor moves to the first wrapped line of line 24, while the buffer shifts to start at line 3 and end one the first wrapped line of line 24.
  • Press the "down" key again. The cursor jumps to the first wrapped line of line 25. The buffer now ranges from line 6 to the first wrapped line of line 25. -- This is incorrect, the cursor shouldn't skip past wrapped lines when moving down.
  • Press the "down" key again. The cursor jumps to the first wrapped line of line 26. The buffer now ranges from line 9 to the first wrapped line of line 26. -- This is incorrect, the cursor shouldn't skip past wrapped lines when moving down.
  • Press the "down" key again. Nothing happens, presumably because there are only wrapped lines remaining, which it attempts to skip past. -- This is incorrect, it should move to the 2nd wrapped line of line 26.
  • Press "end". Cursor jumps to end of the wrapped line -- Correct behavior
  • Press "end" again. Nothing happens. -- Incorrect behavior. The cursor should move to the end of the next wrapped line in line 26 and the buffer should move to include that wrapped line if required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions