Skip line offset on out of range line numbers
This commit is contained in:
@@ -231,6 +231,10 @@ public class CodeInsightUtils {
|
||||
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
|
||||
if (document == null) return null;
|
||||
|
||||
if (line >= document.getLineCount()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int lineStartOffset = document.getLineStartOffset(line);
|
||||
return CharArrayUtil.shiftForward(document.getCharsSequence(), lineStartOffset, " \t");
|
||||
}
|
||||
@@ -240,6 +244,10 @@ public class CodeInsightUtils {
|
||||
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
|
||||
if (document == null) return null;
|
||||
|
||||
if (line >= document.getLineCount()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int lineStartOffset = document.getLineEndOffset(line);
|
||||
return CharArrayUtil.shiftBackward(document.getCharsSequence(), lineStartOffset, " \t");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user