Skip to content

Commit 4206c36

Browse files
committed
fix(sketch): add project disposal check in CodeHighlightSketch #288
1 parent 6640073 commit 4206c36

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/lint/PsiErrorCollector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ object PsiErrorCollector {
153153
.filter {
154154
it.isApplicable(psiFile.language)
155155
&& it.displayKey?.id !in frontEndSkipError
156-
&& it.defaultLevel.severity == HighlightSeverity.WARNING || it.defaultLevel.severity == HighlightSeverity.ERROR
156+
&& it.defaultLevel.severity == HighlightSeverity.ERROR
157157
}
158158

159159
toolWrappers.forEach {

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/CodeHighlightSketch.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ open class CodeHighlightSketch(
219219
isShowLineNo: Boolean? = false,
220220
): EditorEx {
221221
val editor: EditorEx = ReadAction.compute<EditorEx, Throwable> {
222-
EditorFactory.getInstance().createViewer(document, project, EditorKind.PREVIEW) as EditorEx
222+
if (project.isDisposed) return@compute throw IllegalStateException("Project is disposed")
223+
224+
try {
225+
EditorFactory.getInstance().createViewer(document, project, EditorKind.PREVIEW) as EditorEx
226+
} catch (e: Throwable){
227+
throw e
228+
}
223229
}
224230

225231
disposable.whenDisposed {

0 commit comments

Comments
 (0)