hrev48296 adds 1 changeset to branch 'master' old head: d390ebee9e7355ca364f0e105374a33907a5a7cb new head: 29bce877071294445ba4aa055c56dfa893a1a59c overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=29bce87+%5Ed390ebe ---------------------------------------------------------------------------- 29bce87: StyledEdit: ensure caret position gets set correctly * When opening documents without be:caret_position, StyledEdit would place the cursor at the end of the file. _LoadAttrs() intended to set it to the beginning; however, a check for an existing BRect for positioning the window would return early, preventing the caret position to be set. Fixes #11463 [ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev48296 Commit: 29bce877071294445ba4aa055c56dfa893a1a59c URL: http://cgit.haiku-os.org/haiku/commit/?id=29bce87 Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> Date: Fri Nov 14 03:11:12 2014 UTC Ticket: https://dev.haiku-os.org/ticket/11463 ---------------------------------------------------------------------------- 1 file changed, 9 insertions(+), 9 deletions(-) src/apps/stylededit/StyledEditWindow.cpp | 18 +++++++++--------- ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 9ba1cae..04cc20b 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -1331,6 +1331,15 @@ StyledEditWindow::_LoadAttrs() if (documentNode.InitCheck() != B_OK) return; + // info about position of caret may live in the file attributes + int32 position = 0; + if (documentNode.ReadAttr("be:caret_position", B_INT32_TYPE, 0, + &position, sizeof(position)) != sizeof(position)) + position = 0; + + fTextView->Select(position, position); + fTextView->ScrollToOffset(position); + BRect newFrame; ssize_t bytesRead = documentNode.ReadAttr(kInfoAttributeName, B_RECT_TYPE, 0, &newFrame, sizeof(BRect)); @@ -1346,15 +1355,6 @@ StyledEditWindow::_LoadAttrs() MoveTo(newFrame.left, newFrame.top); ResizeTo(newFrame.Width(), newFrame.Height()); } - - // info about position of caret may live in the file attributes - int32 position = 0; - if (documentNode.ReadAttr("be:caret_position", B_INT32_TYPE, 0, - &position, sizeof(position)) != sizeof(position)) - position = 0; - - fTextView->Select(position, position); - fTextView->ScrollToOffset(position); }