Skip to content

Commit

Permalink
fix(line numbers): ClassCastException when disable line wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Li Guanglin committed Jun 27, 2023
1 parent 1ae6c14 commit 64fd499
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,14 @@ private void drawLineNumbers(Canvas canvas) {
// Draw others line number
float y;
final float offsetY = firstBaselineToTopHeight - getTextSize() * 0.14f;
final ScrollView scrollView = (ScrollView) getParent();
// Range of current visible area, drawing line number only near the visible area
final int top = scrollView.getScrollY() - 100;
final int bottom = scrollView.getScrollY() + scrollView.getHeight();
int top = Integer.MIN_VALUE;
int bottom = Integer.MAX_VALUE;
if (getParent() instanceof ScrollView) {
ScrollView scrollView = (ScrollView) getParent();
// Set range of current visible area, drawing line number only near the visible area
top = scrollView.getScrollY() - 100;
bottom = scrollView.getScrollY() + scrollView.getHeight();
}

final int count = getLineCount();
final Editable text = getText();
Expand Down Expand Up @@ -251,7 +255,7 @@ public boolean getLineNumbersEnabled() {
}

public boolean setLineNumbersEnabled(final boolean enable) {
final boolean prev = _hlEnabled;
final boolean prev = _nuEnabled;

if (enable != _nuEnabled) {
_nuEnabled = enable;
Expand Down

0 comments on commit 64fd499

Please sign in to comment.