pub fn render_code_block(
code: &str,
lang: Option<&str>,
ss: &SyntaxSet,
width: usize,
) -> Vec<Vec<InlineSegment>>Expand description
Render a code block with syntect syntax highlighting.
width == 0 preserves the historical “no wrap” behavior so internal
callers (and tests) that don’t pass a viewport still work. Any other
value hard-wraps the highlighted output at display-width boundaries —
LLMs frequently emit tables inside code fences, and the un-wrapped
version overflowed the terminal before this parameter existed.
Wrapping happens after syntax highlighting so each chunk keeps its
token color; tabs expand to four spaces first to keep the math
simple (syntect preserves tabs verbatim and a tab stop is variable).