@@ -82,34 +82,38 @@ interface TemplateProvider {
8282 bundle : ResourceBundle ? = null
8383 ): List <VfsLoadedTemplate > {
8484 val bundle = bundle ? : loadMessagesBundle(modalityState, repoRoot)
85+ val templatesToLoad = mutableListOf<VirtualFile >()
8586 val visitor = object : VirtualFileVisitor <Unit >() {
8687 override fun visitFile (file : VirtualFile ): Boolean {
8788 if (! file.isFile || ! file.name.endsWith(" .mcdev.template.json" )) {
8889 return true
8990 }
9091
91- runBlocking(Dispatchers .Unconfined ) {
92- try {
93- createVfsLoadedTemplate(modalityState, file.parent, file, bundle = bundle)
94- ?.let (templates::add)
95- } catch (t: Throwable ) {
96- if (t is ControlFlowException ) {
97- throw t
98- }
99-
100- val attachment = runCatching { Attachment (file.name, file.readText()) }.getOrNull()
101- if (attachment != null ) {
102- thisLogger().error(" Failed to load template ${file.path} " , t, attachment)
103- } else {
104- thisLogger().error(" Failed to load template ${file.path} " , t)
105- }
106- }
107- }
92+ templatesToLoad + = file
10893
10994 return true
11095 }
11196 }
11297 VfsUtilCore .visitChildrenRecursively(repoRoot, visitor)
98+
99+ for (file in templatesToLoad) {
100+ try {
101+ createVfsLoadedTemplate(modalityState, file.parent, file, bundle = bundle)
102+ ?.let (templates::add)
103+ } catch (t: Throwable ) {
104+ if (t is ControlFlowException ) {
105+ throw t
106+ }
107+
108+ val attachment = runCatching { Attachment (file.name, file.readText()) }.getOrNull()
109+ if (attachment != null ) {
110+ thisLogger().error(" Failed to load template ${file.path} " , t, attachment)
111+ } else {
112+ thisLogger().error(" Failed to load template ${file.path} " , t)
113+ }
114+ }
115+ }
116+
113117 return templates
114118 }
115119
0 commit comments