Bug 322433

Summary: vi mode: scrolling features all incomplete / broken
Product: [Applications] kate Reporter: Dominik Haumann <dhaumann>
Component: Vi Input ModeAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ehamberg, kdedevel
Priority: NOR    
Version: Git   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed In:

Description Dominik Haumann 2013-07-16 12:23:33 UTC
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

Reproducing 1)
- 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.

Reproducing 2)
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.

Reproducing 3)
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.
Comment 1 Dominik Haumann 2013-07-16 21:37:10 UTC
Proper code can be found in commit
http://commits.kde.org/kate/4e3ba0c43ba031882b9180a91ee05d8f524fb045

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.
Comment 2 Michal Humpula 2013-12-01 15:37:52 UTC
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

REVIEW: 114224

M  +3    -2    part/vimode/katevinormalmode.cpp

http://commits.kde.org/kate/550df13a746a738aa4f220000d3fcd74562821d5