@@ -21,6 +21,16 @@ import com.google.gson.JsonArray
2121 */
2222class WrappingEditorPane : JEditorPane () {
2323 override fun getScrollableTracksViewportWidth (): Boolean = true
24+
25+ override fun getPreferredSize (): Dimension {
26+ // Ensure the preferred width doesn't exceed the parent's width
27+ val preferredSize = super .getPreferredSize()
28+ val parent = parent
29+ if (parent != null && parent.width > 0 ) {
30+ preferredSize.width = parent.width
31+ }
32+ return preferredSize
33+ }
2434}
2535
2636/* *
@@ -212,24 +222,24 @@ class PicoCodeToolWindowContent(private val project: Project) {
212222 .replace(Regex (" ^- (.+)$" , RegexOption .MULTILINE ), " <li>$1</li>" )
213223 .replace(Regex (" ^\\ * (.+)$" , RegexOption .MULTILINE ), " <li>$1</li>" )
214224
215- // Restore code blocks with proper styling
225+ // Restore code blocks with proper styling and wrapping
216226 codeBlockPlaceholders.forEachIndexed { index, content ->
217227 val escapedContent = content
218228 .replace(" &" , " &" )
219229 .replace(" <" , " <" )
220230 .replace(" >" , " >" )
221231 html = html.replace(" ###CODEBLOCK${index} ###" ,
222- " <pre style='background-color: rgba(127, 127, 127, 0.1); padding: 8px; border-radius: 4px; overflow-x: auto; border: 1px solid rgba(127, 127, 127, 0.2);'><code>$escapedContent </code></pre>" )
232+ " <pre style='background-color: rgba(127, 127, 127, 0.1); padding: 8px; border-radius: 4px; border: 1px solid rgba(127, 127, 127, 0.2); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word ;'><code>$escapedContent </code></pre>" )
223233 }
224234
225- // Restore inline code with proper styling
235+ // Restore inline code with proper styling and wrapping
226236 inlineCodePlaceholders.forEachIndexed { index, content ->
227237 val escapedContent = content
228238 .replace(" &" , " &" )
229239 .replace(" <" , " <" )
230240 .replace(" >" , " >" )
231241 html = html.replace(" ###INLINECODE${index} ###" ,
232- " <code style='background-color: rgba(127, 127, 127, 0.15); padding: 2px 4px; border-radius: 3px;'>$escapedContent </code>" )
242+ " <code style='background-color: rgba(127, 127, 127, 0.15); padding: 2px 4px; border-radius: 3px; word-wrap: break-word; overflow-wrap: break-word; '>$escapedContent </code>" )
233243 }
234244
235245 // Wrap consecutive list items in <ul> tags
@@ -240,7 +250,7 @@ class PicoCodeToolWindowContent(private val project: Project) {
240250 // Convert line breaks (but not inside pre/code tags)
241251 html = html.replace(" \n " , " <br/>" )
242252
243- return " <html><body style='font-family: sans-serif; font-size: 11px; width: 100%;'>$html </body></html>"
253+ return " <html><body style='font-family: sans-serif; font-size: 11px; width: 100%; word-wrap: break-word; overflow-wrap: break-word; '>$html </body></html>"
244254 }
245255
246256 private fun renderChatHistory () {
0 commit comments