Skip to content

Commit ade7806

Browse files
committed
Less: eliminate a couple of source.lines() calls
Not all Source implementations implement lines() method causing NPE in less.
1 parent 239d6e0 commit ade7806

File tree

1 file changed

+4
-7
lines changed
  • builtins/src/main/java/org/jline/builtins

1 file changed

+4
-7
lines changed

builtins/src/main/java/org/jline/builtins/Less.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ private void moveToPreviousMatch(boolean spanFiles) throws IOException {
11271127
String newSource = sources.get(--sourceIdx).getName();
11281128
try {
11291129
openSource();
1130-
firstLineToDisplay = (int)(long)sources.get(sourceIdx).lines();
1130+
moveTo(Integer.MAX_VALUE);
11311131
moveToPreviousMatch(true);
11321132
} catch (FileNotFoundException exp) {
11331133
ssp.restore(newSource);
@@ -1166,12 +1166,9 @@ void moveForward(int lines) throws IOException {
11661166
display.clear();
11671167
}
11681168
if (lines == Integer.MAX_VALUE) {
1169-
Long allLines = sources.get(sourceIdx).lines();
1170-
if (allLines != null) {
1171-
firstLineToDisplay = (int)(long)allLines;
1172-
for (int l = 0; l < height - 1; l++) {
1173-
firstLineToDisplay = prevLine2display(firstLineToDisplay, dpCompiled).getU();
1174-
}
1169+
moveTo(Integer.MAX_VALUE);
1170+
for (int l = 0; l < height - 1; l++) {
1171+
firstLineToDisplay = prevLine2display(firstLineToDisplay, dpCompiled).getU();
11751172
}
11761173
}
11771174
while (--lines >= 0) {

0 commit comments

Comments
 (0)