<table><tr><td style="">dhaumann created this revision.<br />dhaumann added a reviewer: cullmann.<br />Restricted Application added projects: Kate, Frameworks.<br />Restricted Application added a subscriber: Frameworks.<br />dhaumann requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D10054" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This patch fixes a corner case for the following setup:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">enable "[x] Scroll past end of document"</li>
<li class="remarkup-list-item">disable dynamic word wrap (i.e. you see a horizontal scrollbar for long lines)</li>
<li class="remarkup-list-item">open a document with several lines, where the last line</li>
<li class="remarkup-list-item">make sure the last line is NOT empty</li>
</ul>

<p>Let's say the last two lines look as follows</p>

<p>yy|yy # '|' denoes the cursor position<br />
zzzzz</p>

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

<p>Now press 'cursor down'.</p>

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

<p>Expected behavior is that the cursor position goes one line down,<br />
but the scroll position remains completely unchanged.</p>

<p>The bug here is the following if clause:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">} else if (c > viewLineOffset(startPos(), linesDisplayed() - m_minLinesVisible - 1)) {
    KTextEditor::Cursor scroll = viewLineOffset(c, -(linesDisplayed() - m_minLinesVisible - 1));
    scrollPos(scroll, false, calledExternally);
}</pre></div>

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

<p>The proposed fix here is to not compare cursor positions, but only<br />
the lines. Clearly, 28 < 28 is not true, leading to no change in<br />
the scroll position.</p>

<p>BIG: 306745<br />
FIXED-IN: KDE Frameworks 5.43</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>make test</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>BRANCH</strong><div><div>FixScrollPastEnd (branched from master)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D10054" rel="noreferrer">https://phabricator.kde.org/D10054</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/view/kateviewinternal.cpp</div></div></div><br /><div><strong>To: </strong>dhaumann, cullmann<br /><strong>Cc: </strong>Frameworks, michaelh, kevinapavew, ngraham, demsking, cullmann, sars, dhaumann<br /></div>