Skip to content

Commit f8ce399

Browse files
author
Kirill Rakhman
committed
fix NPE
Fixes #1
1 parent 29bea85 commit f8ce399

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/kotlin/de/rakhman/angular_split_buttons/OpenAngularActions.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ abstract class AbstractOpenAngularAction : AnAction() {
1515
abstract val extensions: Map<String, Icon>
1616

1717
override fun update(e: AnActionEvent) {
18-
val file = e.getData(CommonDataKeys.PSI_FILE)!!
19-
val sibling = getSibling(file)
18+
val file = e.getData(CommonDataKeys.PSI_FILE)
19+
val sibling = file?.let { getSibling(it) }
2020

21-
e.presentation.isEnabledAndVisible = !hasMatchingExtension(file) && sibling != null
21+
e.presentation.isEnabledAndVisible = file != null && sibling != null && !hasMatchingExtension(file)
2222
e.presentation.text = "Open ${sibling?.name}"
2323
e.presentation.icon = sibling?.name?.substringAfterLast(".")?.let {
2424
extensions[it.lowercase()]

0 commit comments

Comments
 (0)