<table><tr><td style="">jsalatas updated this revision to Diff 11494.<br />jsalatas added a comment.
</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/D4538" rel="noreferrer">View Revision</a></tr></table><br /><div><div><ol class="remarkup-list">
<li class="remarkup-list-item">I abandoned the 3rd issue I mention in the summary about the line <tt style="background: #ebebeb; font-size: 13px;">scrollPos(max, max.column(), calledExternally);</tt> as I could neither verify nor disprove if this was intended or not.</li>
</ol>
<ol class="remarkup-list" start="2">
<li class="remarkup-list-item">In <tt style="background: #ebebeb; font-size: 13px;">cursorToCoordinate()</tt> I added an extra check to see if we are behind end of line and return and invalid point (-1, -1):</li>
</ol>
<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);">if (cursor.column() > layout.lineLayout().textLength()) {
return QPoint(-1, -1);
}</pre></div>
<p>as according to QT's documentation (<a href="http://doc.qt.io/qt-5/qtextline.html#cursorToX" class="remarkup-link" target="_blank" rel="noreferrer">http://doc.qt.io/qt-5/qtextline.html#cursorToX</a>)</p>
<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>If cursorPos is not a valid cursor position, the nearest valid cursor position will be used instead, and cursorPos will be modified to point to this valid cursor position.</p></blockquote>
<p>and without this extra check, the "behind end of line should give an invalid cursor" tests in kateview_test.cpp would fail.</p>
<ol class="remarkup-list" start="3">
<li class="remarkup-list-item">I also added the relevant tests to kateview_test.cpp, as per cullmann's feedback.</li>
</ol>
<ol class="remarkup-list" start="4">
<li class="remarkup-list-item">KDevelop seems to work.</li>
</ol>
<p>I have checked it and I didn't see any issues to the Navigation Widget popup tooltips which indeed seems to extensively use coversions between cursors and coordinates, as mentioned by brauch. Furthermore:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">cursorPositionCoordinates isn't used in kdevelop and kdevplatform, so the 2nd issue described in the summary shouldn't affect kdevelop and kdevplatform in any way.</li>
<li class="remarkup-list-item">1st issue in the summary is related to cursors/positions at the end of line, so my intuition suggests that it wouldn't be related to any context related to kdevelop. :)</li>
</ul></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>CHANGES SINCE LAST UPDATE</strong><div><a href="https://phabricator.kde.org/D4538?vs=11137&id=11494" rel="noreferrer">https://phabricator.kde.org/D4538?vs=11137&id=11494</a></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D4538" rel="noreferrer">https://phabricator.kde.org/D4538</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>autotests/src/kateview_test.cpp<br />
src/view/kateview.cpp<br />
src/view/kateviewinternal.cpp</div></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>jsalatas, Frameworks, Plasma, KTextEditor<br /><strong>Cc: </strong>brauch, cullmann, plasma-devel, kwrite-devel, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol<br /></div>