@@ -16,6 +16,13 @@ import com.google.gson.Gson
1616import com.google.gson.JsonObject
1717import com.google.gson.JsonArray
1818
19+ /* *
20+ * Custom JEditorPane that tracks viewport width for proper HTML wrapping
21+ */
22+ class WrappingEditorPane : JEditorPane () {
23+ override fun getScrollableTracksViewportWidth (): Boolean = true
24+ }
25+
1926/* *
2027 * PicoCode RAG Chat Window
2128 * Simple chat interface that communicates with PicoCode backend
@@ -233,7 +240,7 @@ class PicoCodeToolWindowContent(private val project: Project) {
233240 // Convert line breaks (but not inside pre/code tags)
234241 html = html.replace(" \n " , " <br/>" )
235242
236- return " <html><body style='font-family: sans-serif; font-size: 11px;'>$html </body></html>"
243+ return " <html><body style='font-family: sans-serif; font-size: 11px; width: 100%; '>$html </body></html>"
237244 }
238245
239246 private fun renderChatHistory () {
@@ -253,17 +260,14 @@ class PicoCodeToolWindowContent(private val project: Project) {
253260 BorderFactory .createLineBorder(borderColor, 1 )
254261 )
255262
256- // Use JEditorPane for HTML/Markdown rendering
257- val editorPane = JEditorPane ()
263+ // Use JEditorPane for HTML/Markdown rendering with proper width tracking
264+ val editorPane = WrappingEditorPane ()
258265 editorPane.contentType = " text/html"
259266 editorPane.editorKit = HTMLEditorKit ()
260267 editorPane.text = markdownToHtml(msg.message)
261268 editorPane.isEditable = false
262269 editorPane.isOpaque = true
263270
264- // Set preferred size to prevent excessive growth
265- editorPane.preferredSize = null
266-
267271 // Use theme-aware background colors
268272 editorPane.background = if (msg.sender == " You" )
269273 JBColor .namedColor(" EditorPane.inactiveBackground" , JBColor (0xE6F0FF , 0x2D3239 ))
0 commit comments