@@ -65,11 +65,11 @@ class ColorLineMarkerProvider : LineMarkerProvider {
6565 ColorIcon (12 , color),
6666 FunctionUtil .nullConstant<Any , String >(),
6767 GutterIconNavigationHandler handler@{ _, psiElement ->
68- if (! psiElement.isWritable || ! element .isValid) {
68+ if (psiElement == null || ! psiElement.isWritable || ! psiElement .isValid || ! workElement.isPsiValid ) {
6969 return @handler
7070 }
7171
72- val editor = PsiEditorUtil .findEditor(element ) ? : return @handler
72+ val editor = PsiEditorUtil .findEditor(psiElement ) ? : return @handler
7373
7474 val picker = ColorPicker (map, editor.component)
7575 val newColor = picker.showDialog()
@@ -117,18 +117,20 @@ class ColorLineMarkerProvider : LineMarkerProvider {
117117 ) : ColorLineMarkerProvider.ColorInfo(
118118 element,
119119 color,
120- GutterIconNavigationHandler handler@{ _, _ ->
121- if (!element.isWritable || !element.isValid) {
120+ GutterIconNavigationHandler handler@{ _, psiElement ->
121+ if (psiElement == null || !psiElement.isValid ||
122+ !workElement.isPsiValid || workElement.sourcePsi?.isWritable != true
123+ ) {
122124 return @handler
123125 }
124126
125- val editor = PsiEditorUtil .findEditor(element ) ? : return @handler
126- if (JVMElementFactories .getFactory(element .language, element .project) == null) {
127+ val editor = PsiEditorUtil .findEditor(psiElement ) ? : return @handler
128+ if (JVMElementFactories .getFactory(psiElement .language, psiElement .project) == null) {
127129 // The setColor methods used here require a JVMElementFactory. Unfortunately the Kotlin plugin does not
128130 // implement it yet. It is better to not display the color chooser at all than deceiving users after
129131 // after they chose a color
130132 HintManager .getInstance()
131- .showErrorHint(editor, "Can 't change colors in " + element .language.displayName)
133+ .showErrorHint(editor, "Can 't change colors in " + psiElement .language.displayName)
132134 return @handler
133135 }
134136
0 commit comments