Skip to content

Commit 5a4a4a6

Browse files
CopilotMte90
andcommitted
Fix horizontal wrapping: use WrappingEditorPane to track viewport width
Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
1 parent 61fd6a1 commit 5a4a4a6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ide-plugins/src/main/kotlin/com/picocode/PicoCodeToolWindowContent.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import com.google.gson.Gson
1616
import com.google.gson.JsonObject
1717
import 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

Comments
 (0)