Skip to content

Commit cbb7542

Browse files
committed
Fix #103
1 parent 98f0873 commit cbb7542

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# vscode-theme Changelog
44

55
## Unreleased
6+
### Fixed
7+
- #103 - Fix for "Array contains no element matching the predicate"
68

79
## 1.10.1 - 2023-08-21
810

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pluginGroup = com.github.dinbtechit.vscodetheme
44
pluginName = VSCode Theme
55
# SemVer format -> https://semver.org
6-
pluginVersion = 1.10.1
6+
pluginVersion = 1.10.2
77

88
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
99
pluginSinceBuild = 211

src/main/kotlin/com/github/dinbtechit/vscodetheme/VSCodeThemeManager.kt

+12-8
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ class VSCodeThemeManager {
3939
}
4040

4141
fun switchToVSCodeTheme(always: Boolean = false, selectedVSCodeTheme: VSCodeTheme = VSCodeTheme.DARK) {
42-
if (isVSCodeThemeReady()) {
43-
val vscodeTheme =
44-
LafManager.getInstance().installedLookAndFeels.first { it.name == selectedVSCodeTheme.theme }
45-
LafManager.getInstance().currentLookAndFeel = vscodeTheme
46-
if (always) {
47-
val settings = VSCodeThemeSettingsStore.instance
48-
settings.alwaysApply = true
49-
settings.themeName = selectedVSCodeTheme
42+
try {
43+
if (isVSCodeThemeReady()) {
44+
val vscodeTheme =
45+
LafManager.getInstance().installedLookAndFeels.first { it.name == selectedVSCodeTheme.theme }
46+
LafManager.getInstance().currentLookAndFeel = vscodeTheme
47+
if (always) {
48+
val settings = VSCodeThemeSettingsStore.instance
49+
settings.alwaysApply = true
50+
settings.themeName = selectedVSCodeTheme
51+
}
5052
}
53+
} catch (e: Exception) {
54+
throw(Error("Unable to select the default theme $selectedVSCodeTheme", e))
5155
}
5256
}
5357
}

src/main/kotlin/com/github/dinbtechit/vscodetheme/startup/VSCodeStartupNotifyActivity.kt

+22-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import com.intellij.ide.plugins.PluginManagerCore
1212
import com.intellij.ide.ui.LafManager
1313
import com.intellij.notification.Notification
1414
import com.intellij.notification.NotificationGroupManager
15+
import com.intellij.notification.NotificationListener
1516
import com.intellij.notification.NotificationType
1617
import com.intellij.openapi.actionSystem.DefaultActionGroup
1718
import com.intellij.openapi.extensions.PluginId
1819
import com.intellij.openapi.project.Project
1920
import com.intellij.openapi.startup.StartupActivity
20-
21+
import java.awt.Desktop
22+
import java.net.URI
2123

2224

2325
class VSCodeStartupNotifyActivity : StartupActivity {
@@ -31,7 +33,7 @@ class VSCodeStartupNotifyActivity : StartupActivity {
3133
private val updateContent: String by lazy {
3234
//language=HTML
3335
"""
34-
If you find this plugin useful consider sponsoring its development to ensure that the project is actively maintained and improved.
36+
<a href='https://github.com/dinbtechit/vscode-theme/blob/main/CHANGELOG.md'>Click Here</a> to see the change logs.
3537
""".trimIndent()
3638
}
3739

@@ -65,7 +67,9 @@ class VSCodeStartupNotifyActivity : StartupActivity {
6567
if (isReady && getPlugin()?.version != VSCodeThemeSettingsStore.instance.version) {
6668
settings.version = getPlugin()!!.version
6769
if (settings.alwaysApply) {
68-
VSCodeThemeManager.getInstance().switchToVSCodeTheme(selectedVSCodeTheme = settings.themeName)
70+
if (settings.themeName != VSCodeTheme.UNKNOWN) {
71+
VSCodeThemeManager.getInstance().switchToVSCodeTheme(selectedVSCodeTheme = settings.themeName)
72+
}
6973
showNotificationPopup(project)
7074
} else if (settings.showNotificationOnUpdate) {
7175
showNotificationPopup(project)
@@ -114,7 +118,7 @@ class VSCodeStartupNotifyActivity : StartupActivity {
114118
private fun createNotification(
115119
title: String, content: String, type: NotificationType
116120
): Notification {
117-
return NotificationGroupManager.getInstance()
121+
val notification = NotificationGroupManager.getInstance()
118122
.getNotificationGroup("VSCode Theme Notification Group")
119123
.createNotification(content, type)
120124
.setTitle(title)
@@ -131,6 +135,20 @@ class VSCodeStartupNotifyActivity : StartupActivity {
131135
.addAction(DonateAction())
132136
.addAction(StarGithubRepoAction())
133137
// .addAction(DismissNotification(isVSCodeThemeSelected()))
138+
139+
notification.setListener(object : NotificationListener.Adapter() {
140+
override fun hyperlinkActivated(notification: Notification, hyperlinkEvent: javax.swing.event.HyperlinkEvent) {
141+
// Open URL in default browser
142+
if (Desktop.isDesktopSupported()) {
143+
try {
144+
Desktop.getDesktop().browse(URI(hyperlinkEvent.description))
145+
} catch (e: Exception) {
146+
throw(Error("Unable to view the change logs.", e))
147+
}
148+
}
149+
}
150+
})
151+
return notification
134152
}
135153

136154
private fun showFullNotification(project: Project, notification: Notification) {

0 commit comments

Comments
 (0)