Skip to content

Commit 30d504c

Browse files
committed
revert some code
1 parent 950a004 commit 30d504c

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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());

app/src/main/java/net/gsantner/markor/frontend/textview/TextViewUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public static void showSelection(final TextView text, final int start, final int
341341
final int startLine = layout.getLineForOffset(lineStart);
342342
final int startLineTop = layout.getLineTop(startLine);
343343

344-
final int endLine = layout.getLineForOffset(_end) + 1;
344+
final int endLine = layout.getLineForOffset(_end);
345345
final int endLineBottom = layout.getLineBottom(endLine);
346346
final int endLineTop = layout.getLineTop(endLine);
347347
final int lineHeight = endLineBottom - endLineTop;

0 commit comments

Comments
 (0)