Skip to content

Commit 27c98a3

Browse files
committed
fix wrong position when create new array
1 parent 90f1787 commit 27c98a3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

libeditor/src/main/java/com/duy/ide/editor/text/LineManager.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
import com.duy.common.DLog;
2828

29-
import java.util.Arrays;
30-
3129
public class LineManager {
3230
private static final Rect BOUND = new Rect();
3331
private static final String TAG = "LineManager";
@@ -131,10 +129,16 @@ public void updateRealLines(int startLine) {
131129
}
132130
//in some case, edit text not init and return line count is 0
133131
lineCount = Math.max(lineCount, 1);
134-
135132
if (mIsStartRealLine != null) {
136-
mIsStartRealLine = Arrays.copyOf(mIsStartRealLine, lineCount);
137-
mRealLines = Arrays.copyOf(mRealLines, lineCount);
133+
boolean[] dest = new boolean[lineCount];
134+
System.arraycopy(mIsStartRealLine, 0, dest, 0,
135+
Math.max(0, Math.min(mIsStartRealLine.length, startLine - 1)));
136+
mIsStartRealLine = dest;
137+
138+
int[] dest2 = new int[lineCount];
139+
System.arraycopy(mRealLines, 0, dest2, 0,
140+
Math.max(0, Math.min(mRealLines.length, startLine - 1)));
141+
mRealLines = dest2;
138142
} else {
139143
mIsStartRealLine = new boolean[lineCount];
140144
mRealLines = new int[lineCount];

0 commit comments

Comments
 (0)