Commit 6d6a9ad
Related to: [KG-504](https://youtrack.jetbrains.com/issue/KG-504)
## Motivation and Context
The `ContentPartsBuilder` would fail to create a `ContentPart` for text
that ended with `\n` or was followed by a DSL call like `br()` or
`newline()`. This was because the internal `flushTextBuilder` method
checked `caret.offset != 0` to detect pending text. A trailing newline
can reset the offset to 0, causing the check to fail even when the
`textBuilder` is not empty.
This change proposes to check `textBuilder.isNotEmpty()` instead,
ensuring all content is properly flushed.
## Breaking Changes
<!-- Will users need to update their code or configurations? -->
None. This is a non-breaking bug fix.
Co-authored-by: Malte Heuser <malte.heuser@ing.com>
Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com>
1 parent c8513bd commit 6d6a9ad
2 files changed
Lines changed: 13 additions & 1 deletion
File tree
- prompt/prompt-model/src
- commonMain/kotlin/ai/koog/prompt/dsl
- commonTest/kotlin/ai/koog/prompt/dsl
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
918 | 919 | | |
919 | 920 | | |
920 | 921 | | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
921 | 933 | | |
0 commit comments