Skip to content

Commit b08c7e1

Browse files
committed
Fixes exception when the IDE has no foreground color for given attribute
Resolves #121
1 parent 069a1f5 commit b08c7e1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
### Changes
99
- Merged changes from JetBrains plugin template
1010
- [[#120]](https://github.com/Roboroads/laravel-tinker/issues/120) Changes remote tip text in settings
11+
### Fixed
12+
- [[#121]](https://github.com/Roboroads/laravel-tinker/issues/121) Exception when the IDE has no foreground color for given attribute
1113
## [2.3.0]
1214
### Added
1315
- [[#112]](https://github.com/Roboroads/laravel-tinker/issues/112) Adds <kbd>Open new console</kbd> and <kbd>Reopen last console</kbd> actions to the tinker output toolwindow.

src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolwindow.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package nl.deschepers.laraveltinker.toolwindow
22

33
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
4+
import com.intellij.openapi.editor.HighlighterColors
5+
import com.intellij.openapi.editor.colors.EditorColorsManager
46
import com.intellij.openapi.wm.ToolWindow
57
import nl.deschepers.laraveltinker.Strings
68
import nl.deschepers.laraveltinker.settings.GlobalSettingsState
@@ -83,7 +85,7 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) {
8385
}
8486

8587
private fun updateView() {
86-
val color = toHex(DefaultLanguageHighlighterColors.LABEL.defaultAttributes.foregroundColor)
88+
val color = toHex(HighlighterColors.TEXT.defaultAttributes.foregroundColor ?: Color.BLACK)
8789
val timeString = if (pluginSettings.showExecutionStarted) Strings.get("lt.started.at", outputTime) else ""
8890
val highlightedOutput = highlightSyntax("\n" + sanitizeOutput(outputText))
8991

@@ -138,10 +140,10 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) {
138140
}
139141

140142
private fun highlightSyntax(text: String): String {
141-
val stringColor = DefaultLanguageHighlighterColors.STRING.defaultAttributes.foregroundColor
142-
val numberColor = DefaultLanguageHighlighterColors.NUMBER.defaultAttributes.foregroundColor
143+
val stringColor = DefaultLanguageHighlighterColors.STRING.defaultAttributes.foregroundColor ?: Color.BLACK
144+
val numberColor = DefaultLanguageHighlighterColors.NUMBER.defaultAttributes.foregroundColor ?: Color.BLACK
143145
val propColor = DefaultLanguageHighlighterColors.INSTANCE_FIELD.defaultAttributes
144-
.foregroundColor
146+
.foregroundColor ?: Color.BLACK
145147

146148
val regex = Regex("(.*\n=&gt;)(.*)", RegexOption.DOT_MATCHES_ALL)
147149

0 commit comments

Comments
 (0)