Skip to content

Commit 7abdc3b

Browse files
committed
fix #3418
maintain vertical cursor positon with respect to top view when resizing view (soft line wrap, recalculating width)
1 parent d3fa549 commit 7abdc3b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/qcodeedit/lib/qeditor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,6 +4292,7 @@ void QEditor::wheelEvent(QWheelEvent *e)
42924292
void QEditor::resizeEvent(QResizeEvent *)
42934293
{
42944294
const QSize viewportSize = viewport()->size();
4295+
bool cursorIsVisible = isCursorVisible(); // check cursor visibility before changing scrollbars, as it may change after
42954296

42964297
if ( flag(HardLineWrap)||flag(LineWidthConstraint) ){
42974298
horizontalScrollBar()->setMaximum(qMax(0, m_LineWidth - viewportSize.width()));
@@ -4308,11 +4309,11 @@ void QEditor::resizeEvent(QResizeEvent *)
43084309

43094310
setVerticalScrollBarMaximum();
43104311

4311-
emit visibleLinesChanged();
4312-
//qDebug("page step : %i", viewportSize.height() / ls);
4312+
if ( cursorIsVisible && flag(LineWrap) ){
4313+
ensureCursorVisible(KeepDistanceFromViewTop);
4314+
}
43134315

4314-
//if ( isCursorVisible() && flag(LineWrap) )
4315-
// ensureCursorVisible();
4316+
emit visibleLinesChanged();
43164317
}
43174318

43184319
/*!

0 commit comments

Comments
 (0)