fix: preserve blank lines in code blocks when submitting messages

The `on:submit` handlers in Chat.svelte called `.replaceAll('\n\n', '\n')`
on the entire message content before passing it to `submitHandler`. This
blindly collapsed all double newlines into single newlines, which stripped
blank lines inside code blocks — destroying intentional formatting.

Removed the `.replaceAll('\n\n', '\n')` from both submit handlers so that
message content is passed through unchanged.

Fixes #20302

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeremy Heng 2026-04-06 21:38:59 +08:00
parent c40ea7f29d
commit 743eef55a5

View file

@ -2951,7 +2951,7 @@
if (e.detail || files.length > 0) {
await tick();
submitHandler(e.detail.replaceAll('\n\n', '\n'));
submitHandler(e.detail);
}
}}
/>
@ -2994,7 +2994,7 @@
clearDraft();
if (e.detail || files.length > 0) {
await tick();
submitHandler(e.detail.replaceAll('\n\n', '\n'));
submitHandler(e.detail);
}
}}
/>