Skip to content

Commit

Permalink
Fix scrolling to top line (texstudio-org#3626)
Browse files Browse the repository at this point in the history
  • Loading branch information
octaeder authored May 3, 2024
1 parent 67b37ea commit 9971c78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/qcodeedit/lib/qeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5815,15 +5815,7 @@ void QEditor::scrollToFirstLine(int l){

const qreal ls = document()->getLineSpacing();
const qreal ypos = m_doc->y(l-1);
const qreal yval = verticalOffset();
const int ylen = viewport()->height();
const qreal yend = ypos + ylen;

if ( ypos < yval )
verticalScrollBar()->setValue(qFloor(ypos / ls));
else if ( yend > (yval + ylen) )
verticalScrollBar()->setValue(qFloor(1. + (yend - ylen) / ls));

verticalScrollBar()->setValue(qRound(ypos / ls));
}

void QEditor::setCursorSurroundingLines(int s){
Expand Down
4 changes: 2 additions & 2 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3598,8 +3598,8 @@ void Texstudio::restoreSession(const Session &s, bool showProgress, bool warnMis
col = 0;
}
}
edView->editor->setCursorPosition(line, col);
edView->editor->scrollToFirstLine(f.firstLine);
edView->editor->setCursorPosition(line, col, false);
edView->editor->scrollToFirstLine(f.firstLine+1);
edView->document->foldLines(f.foldedLines);
editors->moveToTabGroup(edView, f.editorGroup, -1);
} else {
Expand Down

0 comments on commit 9971c78

Please sign in to comment.