@@ -34,8 +34,10 @@ import com.intellij.openapi.util.text.StringUtil
34
34
import com.intellij.openapi.vfs.VirtualFile
35
35
import com.intellij.psi.PsiManager
36
36
import cc.unitmesh.devti.util.whenDisposed
37
+ import com.intellij.openapi.ui.VerticalFlowLayout
37
38
import com.intellij.testFramework.LightVirtualFile
38
39
import com.intellij.ui.components.JBPanel
40
+ import com.intellij.ui.components.panels.VerticalLayout
39
41
import com.intellij.util.concurrency.annotations.RequiresReadLock
40
42
import com.intellij.util.ui.JBEmptyBorder
41
43
import com.intellij.util.ui.JBUI
@@ -162,32 +164,38 @@ open class CodeHighlightSketch(
162
164
}
163
165
}
164
166
165
- val parse = CodeFence .parse(editorFragment!! .editor.document.text)
166
- var panel: JComponent ? = null
167
- when (parse.originLanguage) {
168
- " diff" , " patch" -> {
169
- val langSketch = LanguageSketchProvider .provide(" patch" )?.create(project, parse.text) ? : return
170
- panel = langSketch.getComponent()
171
- langSketch.onDoneStream(allText)
172
- }
167
+ val codes = CodeFence .parseAll(editorFragment!! .editor.document.text)
168
+ val blockedPanel = JPanel (VerticalLayout (JBUI .scale(0 )))
173
169
174
- " html" -> {
175
- val langSketch = LanguageSketchProvider .provide(" html" )?.create(project, parse.text) ? : return
176
- panel = langSketch.getComponent()
177
- langSketch.onDoneStream(allText)
178
- }
170
+ codes.forEach { code ->
171
+ var panel: JComponent ? = null
172
+ when (code.originLanguage) {
173
+ " diff" , " patch" -> {
174
+ val langSketch = LanguageSketchProvider .provide(" patch" )?.create(project, code.text) ? : return
175
+ panel = langSketch.getComponent()
176
+ langSketch.onDoneStream(allText)
177
+ }
178
+
179
+ " html" -> {
180
+ val langSketch = LanguageSketchProvider .provide(" html" )?.create(project, code.text) ? : return
181
+ panel = langSketch.getComponent()
182
+ langSketch.onDoneStream(allText)
183
+ }
179
184
180
- " bash" , " shell" -> {
181
- val langSketch = LanguageSketchProvider .provide(" shell" )?.create(project, parse.text) ? : return
182
- panel = langSketch.getComponent()
183
- langSketch.onDoneStream(allText)
185
+ " bash" , " shell" -> {
186
+ val langSketch = LanguageSketchProvider .provide(" shell" )?.create(project, code.text) ? : return
187
+ panel = langSketch.getComponent()
188
+ langSketch.onDoneStream(allText)
189
+ }
184
190
}
185
- }
186
191
187
- if (panel == null ) return
192
+ if (panel == null ) return @forEach
193
+
194
+ panel.border = JBEmptyBorder (4 )
195
+ blockedPanel.add(panel)
196
+ }
188
197
189
- panel.border = JBEmptyBorder (4 )
190
- add(panel, BorderLayout .SOUTH )
198
+ add(blockedPanel, BorderLayout .SOUTH )
191
199
192
200
editorFragment?.updateExpandCollapseLabel()
193
201
0 commit comments