@@ -269,24 +269,19 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
269269
270270 @ Override
271271 protected void onFragmentFirstTimeVisible () {
272- _hlEditor .recomputeHighlighting (); // Run before setting scroll position
273- int line = -1 ;
274- int startPosition = _appSettings .getLastEditPosition (_document .path , 0 );
275-
276272 final Bundle args = getArguments ();
277- if (args != null ) {
278- if (args .containsKey (Document .EXTRA_FILE_LINE_NUMBER )) {
279- line = args .getInt (Document .EXTRA_FILE_LINE_NUMBER );
273+ int startPos = _appSettings .getLastEditPosition (_document .path , _hlEditor .length ());
274+ if (args != null && args .containsKey (Document .EXTRA_FILE_LINE_NUMBER )) {
275+ final int lno = args .getInt (Document .EXTRA_FILE_LINE_NUMBER );
276+ if (lno >= 0 ) {
277+ startPos = TextViewUtils .getIndexFromLineOffset (_hlEditor .getText (), lno , 0 );
278+ } else {
279+ startPos = _hlEditor .length ();
280280 }
281281 }
282282
283- if (line > -1 ) {
284- TextViewUtils .getIndexFromLineOffset (_hlEditor .getText (), line , 0 );
285- TextViewUtils .setSelectionAndShow (_hlEditor , startPosition );
286- } else {
287- final int scrollY = _appSettings .getLastEditScrollY (_document .path , 0 );
288- _verticalScrollView .setScrollY (scrollY );
289- }
283+ _hlEditor .recomputeHighlighting (); // Run before setting scroll position
284+ TextViewUtils .setSelectionAndShow (_hlEditor , startPos );
290285
291286 // Fade in to hide initial jank
292287 _hlEditor .post (() -> _hlEditor .animate ().alpha (1 ).setDuration (250 ).start ());
0 commit comments