Skip to content

Commit

Permalink
Use namedColorOrNull instead of marker for color retrieval (#142) (#493)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Senohrabek <[email protected]>
  • Loading branch information
jakub-senohrabek-jb and jakub-senohrabek authored Jul 24, 2024
1 parent c5d1dd6 commit 857e8dd
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager
import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl
import com.intellij.ui.JBColor
import com.intellij.ui.JBColor.marker
import com.intellij.ui.NewUI
import com.intellij.ui.scale.JBUIScale.scale
import com.intellij.util.ui.JBDimension
Expand All @@ -49,15 +48,7 @@ public fun retrieveColor(
default: Color,
): Color = retrieveColorOrNull(key) ?: default

public fun retrieveColorOrNull(key: String): Color? =
try {
JBColor.namedColor(key, marker("JEWEL_JBCOLOR_MARKER")).toComposeColor()
} catch (_: AssertionError) {
// JBColor.marker will throw AssertionError on getRGB/any other color
// for now there is no way to handle non-existing key.
// The way should be introduced in platform
null
}
public fun retrieveColorOrNull(key: String): Color? = JBColor.namedColorOrNull(key)?.toComposeColor()

public fun retrieveColorOrUnspecified(key: String): Color {
val color = retrieveColorOrNull(key)
Expand Down

0 comments on commit 857e8dd

Please sign in to comment.