Skip to content

Commit

Permalink
Check for invalid psi elements in firstParentOfType, fix #3326
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Nov 19, 2024
1 parent 7b76b37 commit cafc3a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Don't insert the right brace when in front of text

### Fixed
* Fix exceptions #3754 and #3326
* Fix exceptions in structure view when command parameters are missing
* Improve error report submitter for long stacktraces
* Fix a parser issue with bidirectional arrow in TikZ
Expand Down
4 changes: 2 additions & 2 deletions src/nl/hannahsten/texifyidea/util/parser/Psi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fun <T : PsiElement> PsiElement.firstParentOfType(clazz: KClass<T>): T? {
if (clazz.java.isAssignableFrom(current.javaClass)) {
return current as? T
}
current = current.parent
current = current.parent?.let { if (it.isValid) it else null }
}
return null
}
Expand All @@ -108,7 +108,7 @@ inline fun <reified T : PsiElement> PsiElement.firstParentOfType(): T? {
if (current is T) {
return current
}
current = current.parent
current = current.parent?.let { if (it.isValid) it else null }
}
return null
}
Expand Down

0 comments on commit cafc3a8

Please sign in to comment.