Bug 306745 - scrolling past document reverts back to the end of the document when you type
Summary: scrolling past document reverts back to the end of the document when you type
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-13 14:30 UTC by amndeep.vass
Modified: 2019-04-13 14:20 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.58
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description amndeep.vass 2012-09-13 14:30:58 UTC
Even though the allow scrolling past the end of the file option is activated, and even though it allows me to view past the end of the file, this feature is basically useless if you are not allowed to type without the end of the file going back to the bottom of the screen.  

Reproducible: Always

Steps to Reproduce:
1. Turn on the scrolling past the end of the document option.
2. Scroll past the end of the document.
3. Type.
Actual Results:  
The end of the file was placed at the end of the screen when I resumed typing.

Expected Results:  
The end of the file should have stayed where it was and allowed me to view past the end of the file while I wrote more code.
Comment 1 Dominik Haumann 2012-12-06 09:48:15 UTC
Which KDE version are you using?
This should be fixed in KDE >= 4.9.
Comment 2 amndeep.vass 2012-12-06 19:40:36 UTC
Whichever version that is associated with Kubuntu 12.04.  I'm sorry that I can't give more information than that as I uninstalled the Kubuntu desktop from Ubuntu so I do not have anything KDE related anymore.
Comment 3 Endrit Veseli 2016-10-05 08:46:41 UTC
I confirm that this bug is still present. 
KDE version 4.14.2. 
KATE version 3.14.2.
Very annoying bug.
Comment 4 Dominik Haumann 2016-10-06 18:02:30 UTC
It's still an issue in KF 5.27 when you type in the very last line.
Comment 5 Dominik Haumann 2018-01-23 16:18:03 UTC
By the way, as far as I understand, this is only about the very last line, correct?
Comment 6 Dominik Haumann 2018-01-24 17:53:54 UTC
Git commit 2bed94b6d463fafbbcb38f68bef90bcf18124cc6 by Dominik Haumann.
Committed on 24/01/2018 at 17:53.
Pushed by dhaumann into branch 'master'.

Fix: View jumps when Scroll past end of document is enabled

Summary:
This patch fixes a corner case for the following setup:
- enable "[x] Scroll past end of document"
- disable dynamic word wrap (i.e. you see a horizontal
  scrollbar for long lines)
- open a document with several lines
- make sure the last line is NOT empty

Let's say the last two lines look as follows

yy|yy # '|' denoes the cursor position
zzzzz

Make sure you scrolled past the end of the document (either
with the mouse or with Ctrl+Down). Note that line 'zzzzz' is
completely visible.

Now press 'cursor down'.

What happens is that the view contents jumps and the scrolling
behavior acts as if "Scroll past end of document" is not enabled.

Expected behavior is that the cursor position goes one line down,
but the scroll position remains completely unchanged.

The bug here is the following if clause:

    } else if (c > viewLineOffset(startPos(), linesDisplayed() - m_minLinesVisible - 1)) {
        KTextEditor::Cursor scroll = viewLineOffset(c, -(linesDisplayed() - m_minLinesVisible - 1));
        scrollPos(scroll, false, calledExternally);
    }

In the buggy case, c==(28, 1), and viewLineOffset()==(28,0).
This triggers the bug that in the last line of the document for
columns > 0 the scroll position is adapted.

The proposed fix here is to not compare cursor positions, but only
the lines. Clearly, 28 < 28 is not true, leading to no change in
the scroll position.
FIXED-IN: KDE Frameworks 5.43

Test Plan: make test

Reviewers: cullmann

Reviewed By: cullmann

Subscribers: #frameworks

Tags: #kate, #frameworks

Differential Revision: https://phabricator.kde.org/D10054

M  +33   -0    autotests/src/kateview_test.cpp
M  +1    -0    autotests/src/kateview_test.h
M  +1    -1    src/view/kateviewinternal.cpp

https://commits.kde.org/ktexteditor/2bed94b6d463fafbbcb38f68bef90bcf18124cc6
Comment 7 Dominik Haumann 2018-03-20 18:52:09 UTC
Git commit e75bde233b9fe6b1a7d24cc63fa9baf9e89de895 by Dominik Haumann.
Committed on 20/03/2018 at 18:51.
Pushed by dhaumann into branch 'master'.

Revert Fix: View jumps when Scroll past end of document is enabled

Unfortunately, this introduced a regression that scrolling down in
dynamically wrapped lines did not move the view at all. We need
to find a better fix, and introduce a unit test.
Related: bug 391838
FIXED-IN: 5.45

M  +2    -0    autotests/src/kateview_test.cpp
M  +1    -1    src/view/kateviewinternal.cpp

https://commits.kde.org/ktexteditor/e75bde233b9fe6b1a7d24cc63fa9baf9e89de895
Comment 8 Dominik Haumann 2018-03-20 18:52:55 UTC
Unfortunately, this change introduced a regression, therefore reopening.
Comment 9 Lothar 2019-04-13 14:20:02 UTC
Git commit cfb0af25bdfac0d8f86b42db0b34a6bc9f9a361e by loh tar.
Committed on 13/04/2019 at 14:19.
Pushed by lohtar into branch 'master'.

ViewInternal: Fix makeVisible(..)

Summary:
- Proper calculation of new position to scroll
- Don't force to center cursor in view in most cases.
  This change looks slightly dangerous but nobody knows
  why that was done. So we give it a try now!
Related: bug 399014
FIXED-IN: 5.58

Differential Revision: https://phabricator.kde.org/D17857

M  +1    -2    autotests/src/kateview_test.cpp
M  +1    -1    src/view/kateview.cpp
M  +6    -3    src/view/kateviewinternal.cpp

https://commits.kde.org/ktexteditor/cfb0af25bdfac0d8f86b42db0b34a6bc9f9a361e