From 7e903a0dd7d765f3ae977b3b424f78e35f8f3cf6 Mon Sep 17 00:00:00 2001 From: Rosemoe <2073412493@qq.com> Date: Mon, 9 Dec 2024 14:04:14 +0800 Subject: [PATCH] fix(lang-monarch): `EnterSupport` is not created when language configuration does not offer `onEnterRules` --- .../rosemoe/sora/langs/monarch/MonarchNewlineHandler.kt | 8 +------- .../sora/langs/monarch/languageconfiguration/loader.kt | 2 +- .../languageconfiguration/model/LanguageConfiguration.kt | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/MonarchNewlineHandler.kt b/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/MonarchNewlineHandler.kt index 40e0ef4ca..c90f8c250 100644 --- a/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/MonarchNewlineHandler.kt +++ b/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/MonarchNewlineHandler.kt @@ -71,13 +71,7 @@ class MonarchNewlineHandler( val brackets = languageConfiguration.brackets val indentationsRules = languageConfiguration.indentationRules - if (enterRules != null) { - enterSupport = - OnEnterSupport( - brackets, - enterRules - ) - } + enterSupport = OnEnterSupport(brackets, enterRules) if (indentationsRules != null) { indentRulesSupport = IndentRulesSupport( diff --git a/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/loader.kt b/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/loader.kt index cf08dead4..fc003f0c0 100644 --- a/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/loader.kt +++ b/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/loader.kt @@ -57,7 +57,7 @@ class LanguageConfigurationAdapter : JsonAdapter() { var indentationRules: IndentationRule? = null - var onEnterRules: List? = null + var onEnterRules: List = listOf() var autoCloseBefore: String? = null diff --git a/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/LanguageConfiguration.kt b/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/LanguageConfiguration.kt index 608b89471..7ce40be9a 100644 --- a/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/LanguageConfiguration.kt +++ b/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/LanguageConfiguration.kt @@ -53,7 +53,7 @@ data class LanguageConfiguration( /** * The language's rules to be evaluated when pressing Enter. */ - val onEnterRules: List? = null, + val onEnterRules: List = listOf(), /** * The language's auto closing pairs. The 'close' character is automatically inserted with the * 'open' character is typed. If not set, the configured brackets will be used.