Skip to content

Commit f84aad9

Browse files
committed
feat: When theme is not selected. Popup will be displayed to apply theme.
1 parent 32192f4 commit f84aad9

File tree

8 files changed

+52
-32
lines changed

8 files changed

+52
-32
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.idea
33
.qodana
44
build
5-
/.idea/**
5+
.idea/**

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# vscode-theme Changelog
44

55
## [Unreleased]
6+
### Fixed
7+
- [Bug] - Kotlin - Removing incorrect highlighting for catch
68

79
## [1.5.2]
810
- When theme is not selected. Popup will be displayed to apply theme.
@@ -74,4 +76,4 @@
7476
- Added extensive syntax highlighting for Dart/Flutter.
7577

7678
### Fixed
77-
- WelcomeScreen color issues and Toolbar border
79+
- WelcomeScreen color issues and Toolbar border

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pluginGroup = com.github.dinbtechit.vscodetheme
55
pluginName = VSCode Theme
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.5.2
7+
pluginVersion = 1.5.3
88

99
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
# for insight into build numbers and IntelliJ Platform versions.

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,26 @@ class VSCodeThemeManager {
2020

2121
private fun getPlugin(): IdeaPluginDescriptor? = PluginManagerCore.getPlugin(PluginId.getId(pluginId))
2222
fun isVSCodeThemeReady(): Boolean {
23-
val vscodeTheme = LafManager.getInstance().installedLookAndFeels.first { it.name == "VSCode Dark" }
24-
if (vscodeTheme != null && getPlugin()?.isEnabled != null) {
25-
return true
23+
try {
24+
25+
if (getPlugin()?.isEnabled != null) {
26+
val vscodeTheme = LafManager.getInstance().installedLookAndFeels.first { it.name == "VSCode Dark" }
27+
return vscodeTheme != null
28+
}
29+
return false
30+
} catch (e: Exception) {
31+
return false;
2632
}
27-
return false
2833
}
2934

3035
fun switchToVSCodeTheme(always: Boolean = false) {
31-
val vscodeTheme = LafManager.getInstance().installedLookAndFeels.first { it.name == "VSCode Dark" }
32-
LafManager.getInstance().currentLookAndFeel = vscodeTheme
33-
if (always) {
34-
val settings = VSCodeThemeSettingsStore.instance
35-
settings.alwaysApply = true
36-
settings.showNotificationOnUpdate = false
36+
if (isVSCodeThemeReady()) {
37+
val vscodeTheme = LafManager.getInstance().installedLookAndFeels.first { it.name == "VSCode Dark" }
38+
LafManager.getInstance().currentLookAndFeel = vscodeTheme
39+
if (always) {
40+
val settings = VSCodeThemeSettingsStore.instance
41+
settings.alwaysApply = true
42+
}
3743
}
3844
}
3945
}

src/main/kotlin/com/github/dinbtechit/vscodetheme/actions/AlwaysApplyThemeAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.intellij.notification.impl.NotificationsManagerImpl
66
import com.intellij.openapi.actionSystem.AnActionEvent
77
import com.intellij.openapi.project.DumbAwareAction
88

9-
class AlwaysApplyThemeAction: DumbAwareAction("Always") {
9+
class AlwaysApplyThemeAction: DumbAwareAction("Set as Default") {
1010

1111
override fun actionPerformed(e: AnActionEvent) {
1212
VSCodeThemeManager.getInstance().switchToVSCodeTheme(true)

src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/KotlinAnnotator.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ class KotlinAnnotator : BaseAnnotator() {
2222
"JAVA.TYPE_KEYWORD",
2323
DEFAULT_KEYWORD
2424
)
25+
val SECONDARY_KEYWORD_BG: TextAttributesKey = TextAttributesKey.createTextAttributesKey(
26+
"DEFAULT_SECONDARY_KEYWORD_WITH_BG",
27+
DEFAULT_KEYWORD
28+
)
2529
}
2630

2731
override fun getKeywordType(element: PsiElement): TextAttributesKey? {
2832
var type: TextAttributesKey? = null
29-
if (element.elementType is KtKeywordToken || element.text == "catch" ) {
33+
if (element.elementType is KtKeywordToken) {
3034
when (element.text) {
3135
"return", "as" -> type = SECONDARY_KEYWORD
3236
"if", "else", "when", "default", "break", "continue" -> type = SECONDARY_KEYWORD
33-
"try", "catch", "finally", "throw" -> type = SECONDARY_KEYWORD
37+
"try", "finally", "throw" -> type = SECONDARY_KEYWORD
38+
"catch" -> type = SECONDARY_KEYWORD_BG
3439
"for", "while", "do" -> type = SECONDARY_KEYWORD
3540
else -> {}
3641
}

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ import com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction
55
import com.github.dinbtechit.vscodetheme.actions.ApplyThemeAction
66
import com.github.dinbtechit.vscodetheme.actions.DonateAction
77
import com.github.dinbtechit.vscodetheme.icons.VSCodeIcons
8+
import com.github.dinbtechit.vscodetheme.services.ApplicationService
89
import com.github.dinbtechit.vscodetheme.settings.VSCodeThemeSettingsStore
910
import com.intellij.ide.plugins.IdeaPluginDescriptor
1011
import com.intellij.ide.plugins.PluginManagerCore
1112
import com.intellij.ide.ui.LafManager
1213
import com.intellij.notification.Notification
1314
import com.intellij.notification.NotificationGroupManager
1415
import com.intellij.notification.NotificationType
16+
import com.intellij.notification.impl.NotificationsManagerImpl
1517
import com.intellij.openapi.extensions.PluginId
1618
import com.intellij.openapi.project.Project
1719
import com.intellij.openapi.startup.StartupActivity
20+
import com.intellij.openapi.ui.popup.Balloon
1821
import com.intellij.openapi.wm.WindowManager
22+
import com.intellij.ui.BalloonLayoutData
1923
import com.intellij.ui.awt.RelativePoint
2024
import java.awt.Point
2125

@@ -95,22 +99,25 @@ class VSCodeStartupNotifyActivity : StartupActivity {
9599
}
96100

97101
private fun showFullNotification(project: Project, notification: Notification) {
98-
val frame = WindowManager.getInstance().getIdeFrame(project)
99-
if (frame == null) {
102+
try {
103+
// val frame = WindowManager.getInstance().getIdeFrame(project)
104+
// if (frame == null) {
105+
// notification.notify(project)
106+
// return
107+
// }
108+
// val bounds = frame.component.bounds
109+
// val target = RelativePoint(frame.component, Point(bounds.x + bounds.width, 20))
110+
// NotificationsManagerImpl.createBalloon(
111+
// frame,
112+
// notification,
113+
// true, // showCallout
114+
// false, // hideOnClickOutside
115+
// BalloonLayoutData.fullContent(),
116+
// ApplicationService.INSTANCE
117+
// ).show(target, Balloon.Position.atLeft)
118+
notification.notify(project)
119+
} catch(e: Exception) {
100120
notification.notify(project)
101-
return
102121
}
103-
val bounds = frame.component.bounds
104-
val target = RelativePoint(frame.component, Point(bounds.x + bounds.width, 20))
105-
/*NotificationsManagerImpl.createBalloon(
106-
frame,
107-
notification,
108-
true, // showCallout
109-
false, // hideOnClickOutside
110-
BalloonLayoutData.fullContent(),
111-
ApplicationService.INSTANCE
112-
).show(target, Balloon.Position.atLeft)*/
113-
114-
notification.notify(project)
115122
}
116123
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
2-
<idea-plugin>
2+
<idea-plugin require-restart="true">
33
<id>com.github.dinbtechit.vscodetheme</id>
44
<name>VSCode Theme</name>
55
<vendor>dinbtechit</vendor>

0 commit comments

Comments
 (0)