mirror of
https://github.com/chylex/IntelliJ-Rainbow-Brackets.git
synced 2025-05-12 06:34:03 +02:00
Fix #973 File text mismatch
(cherry picked from commit f67bd84af9ac2e96e7831ef7224d57baad0660fb)
This commit is contained in:
parent
ca581dedd6
commit
4b784f5f84
@ -119,17 +119,20 @@ abstract class RainbowHighlightVisitor : HighlightVisitor {
|
||||
private var bigFilesNotified = false
|
||||
|
||||
fun PsiElement.getLineCount(): Int {
|
||||
val doc = containingFile?.let { PsiDocumentManager.getInstance(project).getDocument(it) }
|
||||
if (doc != null) {
|
||||
val spaceRange = textRange ?: TextRange.EMPTY_RANGE
|
||||
try {
|
||||
val doc = containingFile?.let { PsiDocumentManager.getInstance(project).getDocument(it) }
|
||||
if (doc != null) {
|
||||
val spaceRange = textRange ?: TextRange.EMPTY_RANGE
|
||||
|
||||
if (spaceRange.endOffset <= doc.textLength && spaceRange.startOffset < spaceRange.endOffset) {
|
||||
val startLine = doc.getLineNumber(spaceRange.startOffset)
|
||||
val endLine = doc.getLineNumber(spaceRange.endOffset - 1)
|
||||
if (spaceRange.endOffset <= doc.textLength && spaceRange.startOffset < spaceRange.endOffset) {
|
||||
val startLine = doc.getLineNumber(spaceRange.startOffset)
|
||||
val endLine = doc.getLineNumber(spaceRange.endOffset - 1)
|
||||
|
||||
return endLine - startLine + 1
|
||||
return endLine - startLine + 1
|
||||
}
|
||||
}
|
||||
return StringUtil.getLineBreakCount(text ?: "") + 1
|
||||
} catch (e: Throwable) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return StringUtil.getLineBreakCount(text ?: "") + 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user