redhat-developer / redhat-developer/lsp4ij
java.lang.IndexOutOfBoundsException: Wrong line: 1. Available lines count: 1
Open
Nobody has claimed this yet.
bug
folding
- Dominant language
- Java
- Stars
- 344
- Forks
- 113
- Avg merge
- 5h 22m
- Merged PRs (30d)
- 15
Description
I don't know how to reproduce but by playing with JDTLS I had this error:
java.lang.IndexOutOfBoundsException: Wrong line: 1. Available lines count: 1
at com.intellij.openapi.editor.impl.LineSet.checkLineIndex(LineSet.java:197)
at com.intellij.openapi.editor.impl.LineSet.getLineEnd(LineSet.java:191)
at com.intellij.openapi.editor.impl.DocumentImpl.getLineEndOffset(DocumentImpl.java:1018)
at com.redhat.devtools.lsp4ij.features.foldingRange.LSPFoldingRangeBuilder.getStartOffset(LSPFoldingRangeBuilder.java:180)
at com.redhat.devtools.lsp4ij.features.foldingRange.LSPFoldingRangeBuilder.getTextRange(LSPFoldingRangeBuilder.java:151)
at com.redhat.devtools.lsp4ij.features.foldingRange.LSPFoldingRangeBuilder.getTextRange(LSPFoldingRangeBuilder.java:124)
at com.redhat.devtools.lsp4ij.features.foldingRange.LSPFoldingRangeBuilder.buildLanguageFoldRegions(LSPFoldingRangeBuilder.java:68)
at com.intellij.lang.folding.CustomFoldingBuilder.buildFoldRegions(CustomFoldingBuilder.java:43)
at com.intellij.lang.folding.LanguageFolding.buildFoldingDescriptorsNoPlaceholderCaching(LanguageFolding.java:92)
at com.intellij.lang.folding.LanguageFolding.buildFoldingDescriptors(LanguageFolding.java:74)
at com.intellij.codeInsight.folding.impl.FoldingUpdate.getFoldingsFor(FoldingUpdate.java:272)
at com.intellij.codeInsight.folding.impl.FoldingUpdate.getFoldingsFor(FoldingUpdate.java:240)
at com.intellij.codeInsight.folding.impl.FoldingUpdate.getUpdateResult(FoldingUpdate.java:89)
at com.intellij.codeInsight.folding.impl.FoldingUpdate.lambda$updateFoldRegions$0(FoldingUpdate.java:78)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:37)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:240)
at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:43)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:240)
at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:110)
at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:27)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:65)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:241)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:27)
at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:69)
at com.intellij.codeInsight.folding.impl.FoldingUpdate.updateFoldRegions(FoldingUpdate.java:75)
at com.intellij.codeInsight.folding.impl.CodeFoldingManagerImpl.updateFoldRegions(CodeFoldingManagerImpl.java:231)
at com.intellij.codeInsight.folding.impl.CodeFoldingManagerImpl.updateFoldRegionsAsync(CodeFoldingManagerImpl.java:217)
at com.intellij.codeInsight.folding.impl.CodeFoldingPass.doCollectInformation(CodeFoldingPass.java:27)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:57)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:390)
at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:77)
at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:24)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:386)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1133)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:377)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:376)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:352)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:201)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:207)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:350)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:185)
at java.base/java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LSPFoldingRangeBuilder, especially getStartOffset and getTextRange, using the stack trace as the entry point. Investigate how folding ranges are converted to document offsets when the document has one available line; no reproduction or test is provided in the issue. Done means the reported IndexOutOfBoundsException is prevented for this case and folding remains functional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100