From f7bed15d6476a9a5b781e529852908f849c1774e Mon Sep 17 00:00:00 2001 From: Ben Gibson Date: Fri, 16 Dec 2022 20:15:53 +0000 Subject: [PATCH] Fix menu crash on 2022.3 when no host is detected (#274) --- CHANGELOG.md | 1 + README.md | 3 +-- gradle.properties | 2 +- .../uk/co/ben_gibson/git/link/ui/actions/Action.kt | 11 +++++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee483ec..df5d2dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ # GitLink Changelog ## Unreleased +- Fix menu text crash on 2022.3 when no host is detected ## 4.3.0 - 2022-12-11 - Add basic copy Markdown action diff --git a/README.md b/README.md index c835138..8533ef1 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ [![Version](https://img.shields.io/jetbrains/plugin/v/8183-gitlink.svg)](https://plugins.jetbrains.com/plugin/8183-gitlink) [![Rating](https://img.shields.io/jetbrains/plugin/r/stars/8183-gitlink.svg)](https://plugins.jetbrains.com/plugin/8183-gitlink) [![Downloads](https://img.shields.io/jetbrains/plugin/d/8183-gitlink.svg)](https://plugins.jetbrains.com/plugin/8183-gitlink) -[![Backers](https://opencollective.com/gitlink/tiers/backer/badge.svg?label=backer&color=brightgreen)](https://opencollective.com/gitlink) -[![Sponsors](https://opencollective.com/gitlink/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen)](https://opencollective.com/gitlink) +[![Donations](https://opencollective.com/gitlink/tiers/badge.svg?label=sponsor&color=brightgreen)](https://opencollective.com/gitlink) [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua) diff --git a/gradle.properties b/gradle.properties index 1ed92af..866755a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = uk.co.ben_gibson.git.link pluginName = GitLink # SemVer format -> https://semver.org -pluginVersion = 4.3.0 +pluginVersion = 4.3.1 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt index f3e50bf..3038e20 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt @@ -44,12 +44,15 @@ abstract class Action(private val type: Type): DumbAwareAction() { val host = project.service().locate() + if (host == null) { + event.presentation.isEnabledAndVisible = false + return; + } + event.presentation.isEnabled = shouldBeEnabled(event) - host?.let { - event.presentation.icon = it.icon - event.presentation.text = GitLinkBundle.message("actions.${type.key}.title", it.name) - } + event.presentation.icon = host.icon + event.presentation.text = GitLinkBundle.message("actions.${type.key}.title", host.name) } override fun getActionUpdateThread(): ActionUpdateThread {