Scrolling in the vi input mode has several bugs.
1. It does not take text folding into account
2. It does not take the "allow scrolling past document" feature into account
3. It does not take the "auto center lines" feature into account
- fold lines above the cursor
- press 'zz'
Result: The "center" position is calculated relying on the unfolded text. However, if text is folded, the scrolling is pretty much messed up.
Go to the settings in the Editing > "text navigation" tab and enable "Allow scrolling past the end of the document."
- open a document where you can vertically scroll.
- go to the last line (G)
- press 'zz'.
The vi mode will not center the last line, since it thinks scrolling is already at the end of the document. However, if scrolling past the end of the document is allowed, it should center also for these lines.
When scrolling past the end of the document is enabled, and auto-center-cursor is send to e.g. 5 lines, then the amound you are allowed to scroll past the end of the document is reduced by 5-1=4 lines. That is, you cannot scroll such that only the last line is visible. Instead, the last 5 lines are always visible.
That said, all these issues need to be taken into account when doing scrolling operations. Currently, the vi input mode pretty much ignores all these properties.
Proper code can be found in commit
It basically comes down to querying the m_view->textFolding(), and also adhere to
m_view->config()->scrollPastEnd() by then modifying the visible line count by adding m_viewInternal->visibleLines() - m_view->config()->autoCenterLines().
Maybe it would be a good idea to have int KateView::scrollLineCount() const, that takes this stuff into account.
Git commit 550df13a746a738aa4f220000d3fcd74562821d5 by Michal Humpula.
Committed on 30/11/2013 at 15:23.
Pushed by michalhumpula into branch 'master'.
vi-mode: fix computation of zz cmd when folding
M +3 -2 part/vimode/katevinormalmode.cpp