Skip to content

Commit 9eb197e

Browse files
committed
fix(editor): 添加语法高亮器设置的异常处理 #423
防止在某些情况下设置编辑器高亮器时出现的异常导致程序崩溃,通过try-catch块静默处理异常以提高代码的健壮性。
1 parent 4bc33c4 commit 9eb197e

File tree

1 file changed

+5
-1
lines changed
  • core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ object EditorUtil {
111111
.getService(EditorHighlighterFactory::class.java)
112112
.createEditorHighlighter(project, file)
113113

114-
editor.highlighter = highlighter
114+
try {
115+
editor.highlighter = highlighter
116+
} catch (e: Throwable) {
117+
/// do nothing
118+
}
115119

116120
val markupModel: MarkupModelEx = editor.markupModel
117121
(markupModel as EditorMarkupModel).isErrorStripeVisible = false

0 commit comments

Comments
 (0)