yi-editor / yi

The Haskell-Scriptable Editor
GNU General Public License v2.0
1.51k stars 201 forks source link

`zb` behaves incorrect at the bottom of buffers. (vim) #1027

Closed benjamin-travis-summers closed 7 years ago

benjamin-travis-summers commented 7 years ago

To reproduce, go to the end of a buffer (G), and move the view down so that the last line of text is the first line on the screen (zt). From this state, entering zb should move the view so that the last line of text is the last line on the screen, but nothing happens.

(Possibly enlightening behavior: If the cursor is $x lines above the last line of the buffer, entering zb will move the view up $x lines.)

benjamin-travis-summers commented 7 years ago
-- | Move cursor to the bottom of the screen
scrollCursorToBottomB :: BufferM ()
scrollCursorToBottomB = do
    MarkSet _ i _ <- markLines
    r <- winRegionB
    t <- lineOf (regionEnd r - 1)
    scrollB $ i - t

The problem seems to be regionEnd is the last point in the buffer, not the last square on the screen.

I guess the right approach is to figure out which line of the screen the cursor is on, find the height of the window, and use those two values to figure out how many lines to scroll down?

ethercrow commented 7 years ago

Sort of fixed by https://github.com/yi-editor/yi/pull/1029. Scrolling is off by amount of newly displayed wrapped lines, but I don't have a simple solution for that.