Skip to content

Commit d98e789

Browse files
committed
refactor: replace language with IDEA api
1 parent af77121 commit d98e789

File tree

1 file changed

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

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.intellij.openapi.editor.ex.EditorMarkupModel
1616
import com.intellij.openapi.editor.ex.FocusChangeListener
1717
import com.intellij.openapi.editor.ex.MarkupModelEx
1818
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory
19+
import com.intellij.openapi.fileTypes.PlainTextLanguage
1920
import com.intellij.openapi.project.Project
2021
import com.intellij.openapi.vfs.VirtualFile
2122
import com.intellij.testFramework.LightVirtualFile
@@ -32,13 +33,14 @@ object EditorUtil {
3233
disposable: Disposable,
3334
): EditorEx {
3435
var editorText = text
35-
val language = ideaLanguage ?: CodeFence.findLanguage("Plain text")
36-
val ext = if (language.displayName == "Plain text") {
36+
val language = ideaLanguage ?: PlainTextLanguage.INSTANCE
37+
val ext = if (language.displayName == PlainTextLanguage.INSTANCE.displayName) {
3738
CodeFence.lookupFileExt(language.displayName)
3839
} else {
3940
language.associatedFileType?.defaultExtension ?: "Unknown"
4041
}
41-
/// check text easyline starts with Lineno and :, for example: 1:
42+
43+
/// check text easy line starts with Lineno and : for example, 1:
4244
var isShowLineNo = true
4345
editorText.lines().forEach {
4446
if (!it.matches(LINE_NO_REGEX)) {

0 commit comments

Comments
 (0)