Skip to content

Commit a995e62

Browse files
committed
Fix calculate wrong line number
1 parent d0b2740 commit a995e62

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ public void updateRealLines(int startLine) {
127127
if (mIsStartRealLine != null) {
128128
boolean[] dest = new boolean[lineCount];
129129
System.arraycopy(mIsStartRealLine, 0, dest, 0,
130-
Math.max(0, Math.min(mIsStartRealLine.length, startLine - 1)));
130+
Math.max(0, Math.min(mIsStartRealLine.length, startLine)));
131131
mIsStartRealLine = dest;
132132

133133
int[] dest2 = new int[lineCount];
134134
System.arraycopy(mRealLines, 0, dest2, 0,
135-
Math.max(0, Math.min(mRealLines.length, startLine - 1)));
135+
Math.max(0, Math.min(mRealLines.length, startLine)));
136136
mRealLines = dest2;
137137
} else {
138138
mIsStartRealLine = new boolean[lineCount];
@@ -165,7 +165,7 @@ public void updateRealLines(int startLine) {
165165
}
166166
mIsStartRealLine[lineCount - 1] = true;
167167

168-
int realLine = mRealLines[Math.max(0, startLine - 1)]; // the first line is not 0, is 1. We start counting from 1
168+
int realLine = mRealLines[startLine]; // the first line is not 0, is 1. We start counting from 1
169169
for (line = realLine; line < lineCount; line++) {
170170
if (mIsStartRealLine[line]) {
171171
realLine++;

0 commit comments

Comments
 (0)