From 0173f2190d12a0d072b95f20013ebfbbc79b3c26 Mon Sep 17 00:00:00 2001 From: tangcent Date: Mon, 22 Apr 2024 08:05:47 +0800 Subject: [PATCH] fix: fix issue where the configuration was not being loaded before actions were performed (#539) --- .../itangcent/idea/plugin/config/EnhancedConfigReader.kt | 5 +++++ ...aderTest.EmptyRecommendEnhancedConfigReaderTest.log.txt | 7 +++++++ ...ConfigReaderTest.SimpleEnhancedConfigReaderTest.log.txt | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/config/EnhancedConfigReader.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/config/EnhancedConfigReader.kt index ad6578a5..da09a905 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/config/EnhancedConfigReader.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/config/EnhancedConfigReader.kt @@ -71,6 +71,11 @@ class EnhancedConfigReader : BaseConfigReader() { contextSwitchListener.onModuleChange { loadConfigList() } + //fix: https://github.com/tangcent/easy-yapi/issues/1121 + //if the module is null, the contextSwitchListener will not be triggered + if (contextSwitchListener.getModule() == null) { + loadConfigList() + } } finally { notInit = false } diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.EmptyRecommendEnhancedConfigReaderTest.log.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.EmptyRecommendEnhancedConfigReaderTest.log.txt index 13ada9de..e6bc6473 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.EmptyRecommendEnhancedConfigReaderTest.log.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.EmptyRecommendEnhancedConfigReaderTest.log.txt @@ -5,3 +5,10 @@ If you need to enable the built-in recommended configuration.Go to [Preference -> Other Setting -> EasyApi -> Recommend] [DEBUG] load remote config +[TRACE] No config be found +[DEBUG] use built-in config +[DEBUG] use recommend config +[DEBUG] Even useRecommendConfig was true, but no recommend config be selected! + +If you need to enable the built-in recommended configuration.Go to [Preference -> Other Setting -> EasyApi -> Recommend] +[DEBUG] load remote config diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.SimpleEnhancedConfigReaderTest.log.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.SimpleEnhancedConfigReaderTest.log.txt index 098161e5..de9ff646 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.SimpleEnhancedConfigReaderTest.log.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.config.EnhancedConfigReaderTest.SimpleEnhancedConfigReaderTest.log.txt @@ -2,3 +2,7 @@ [DEBUG] use built-in config [DEBUG] use recommend config [DEBUG] load remote config +[TRACE] No config be found +[DEBUG] use built-in config +[DEBUG] use recommend config +[DEBUG] load remote config