Commit 02487d2
committed
fix(chat): prevent panic on UTF-8 boundary when rendering response
When the AI response contains multi-byte characters (e.g. non-ASCII
text adjacent to triple backticks), the byte offset accumulated via
parsed.offset_from() can land in the middle of a UTF-8 character
boundary. The subsequent &buf[offset..] slice then panics at runtime.
Replace the direct slice with buf.get(offset..) which returns None
instead of panicking when the index is out of bounds or misaligned,
and break the loop gracefully in that case.
Fixes #37151 parent e14ea18 commit 02487d2
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3099 | 3099 | | |
3100 | 3100 | | |
3101 | 3101 | | |
3102 | | - | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
3103 | 3107 | | |
3104 | 3108 | | |
3105 | 3109 | | |
| |||
0 commit comments