6
6
package org.rust.ide.intentions
7
7
8
8
import com.intellij.codeInsight.intention.LowPriorityAction
9
+ import com.intellij.ide.ui.LafManager
10
+ import com.intellij.ide.ui.laf.UIThemeBasedLookAndFeelInfo
9
11
import com.intellij.openapi.editor.Editor
10
12
import com.intellij.openapi.project.Project
11
13
import com.intellij.psi.PsiElement
14
+ import com.intellij.util.ui.UIUtil
12
15
import org.rust.cargo.project.model.CargoProject
13
16
import org.rust.cargo.project.workspace.CargoWorkspace
14
17
import org.rust.cargo.toolchain.CargoCommandLine
@@ -40,9 +43,10 @@ class RunCargoExpandIntention : RsElementBaseIntentionAction<RunCargoExpandInten
40
43
val (cargoProject, cargoTarget, crateRelativePath) = ctx
41
44
if (checkNeedInstallCargoExpand(cargoProject.project)) return
42
45
46
+ val theme = if (isUnderDarkTheme()) " Dracula" else " GitHub"
43
47
val additionalArguments = buildList<String > {
44
48
add(" --color=always" )
45
- add(" --theme=GitHub " )
49
+ add(" --theme=$theme " )
46
50
add(" --tests" )
47
51
if (crateRelativePath.isNotEmpty()) {
48
52
add(crateRelativePath.removePrefix(PATH_SEPARATOR ))
@@ -57,6 +61,11 @@ class RunCargoExpandIntention : RsElementBaseIntentionAction<RunCargoExpandInten
57
61
).run (cargoProject, " Expand ${cargoTarget.normName}$crateRelativePath " )
58
62
}
59
63
64
+ private fun isUnderDarkTheme (): Boolean {
65
+ val lookAndFeel = LafManager .getInstance().currentLookAndFeel
66
+ return lookAndFeel is UIThemeBasedLookAndFeelInfo && lookAndFeel.theme.isDark || UIUtil .isUnderDarcula()
67
+ }
68
+
60
69
companion object {
61
70
private const val PATH_SEPARATOR : String = " ::"
62
71
}
0 commit comments