Commit c66f604
fix(userMessageDisplay): paint wrapped lines with the configured bg by finalizing boxAttrs after the bg block
Reported: with custom User Message Display settings, a message long enough
to wrap in the terminal had its highlight only on line 1 — line 2+ rendered
against the terminal default bg.
Two bugs collided to cause this:
1. Latent ordering bug: `boxAttrsObjStr` was computed right after the
padding/border block, before the foreground/background block ran. Every
`boxAttrs.push('backgroundColor:...')` afterwards — including the default-
branch push added in 3114c5b — was silently discarded. So even with
`backgroundColor: 'default'` the Box had no bg; only the inner Text's
theme token was in play, and Ink's Text bg applies to the text cells
but doesn't fill the padded Box width on wrapped lines.
2. For a custom bg (`rgb(r,g,b)`) the patch was only adding `.bgRgb()` to
the chalk chain. That wraps the text content in ANSI bg escapes, but
when Ink word-wraps the message the escape on line 1 doesn't reliably
re-open on line 2, leaving wrapped lines bare.
Fixes:
- Move `boxAttrsObjStr` finalization to after the bg block so every push
(default-theme token and custom rgb) reaches the emitted element attrs.
- For custom bg, also push `backgroundColor:"rgb(r,g,b)"` onto boxAttrs
and textAttrs alongside the existing chalk.bgRgb chain. Box-level bg is
what actually fills the padded width across every wrapped line; Text-
level bg covers the text cells where chalk's state may have been reset.
Verified against CC 2.1.112 cli.js — emitted shapes:
default bg: Box{paddingRight:1,backgroundColor:"userMessageBackground"}
Text{color:"text",backgroundColor:"userMessageBackground"}
custom bg: Box{paddingRight:1,backgroundColor:"rgb(200,80,40)"}
Text{color:"text",backgroundColor:"rgb(200,80,40)"}
chalk.bgRgb(200,80,40)(...)
null bg: Box{paddingRight:1} Text{color:"text"} (unchanged)
Ink's `colorize.js` accepts `"rgb(r,g,b)"` (no spaces) which is exactly
what the `\d+` regex + join produces, even if the input has spaces.
All 228 tests still pass.1 parent 5f4c442 commit c66f604
1 file changed
+20
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
226 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| |||
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
251 | 263 | | |
252 | 264 | | |
253 | 265 | | |
| |||
297 | 309 | | |
298 | 310 | | |
299 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
300 | 318 | | |
301 | 319 | | |
302 | 320 | | |
| |||
0 commit comments