Skip to content

Commit d37f49a

Browse files
committed
Make sure caret is in the top of the view at start
* Fixes #90.
1 parent 1cc0fed commit d37f49a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/windows/EditorWindow.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,14 @@ EditorWindow::WindowActivated(bool active)
810810
// cannot calculate scroll position correctly.
811811
// After the window is activated for the first time, we are sure
812812
// layouting has been completed.
813-
fEditor->SendMessage(SCI_SCROLLCARET, 0, 0);
813+
fEditor->SendMessage(SCI_SCROLLCARET);
814+
// We can safely assume that caret is at the bottom at this point,
815+
// so scroll further down.
816+
int linesOnScreen = fEditor->SendMessage(SCI_LINESONSCREEN);
817+
fEditor->SendMessage(SCI_LINESCROLL, 0, linesOnScreen - 8);
818+
// ...if that assumption is not correct, make sure the caret
819+
// is in the view.
820+
fEditor->SendMessage(SCI_SCROLLCARET);
814821
fActivatedGuard = true;
815822
}
816823
BMessage message(ACTIVE_WINDOW_CHANGED);

0 commit comments

Comments
 (0)