Skip to main content

resolve_carriage_returns

Function resolve_carriage_returns 

Source
pub fn resolve_carriage_returns(s: &str) -> String
Expand description

Resolve carriage-return (\r) progress overwrites in captured output.

CLI tools like git, cargo, and npm use \r to draw in-place progress updates. When stdout is captured (not a TTY), these bytes survive as literal \r characters and produce glued-together lines (#1140). This function emulates terminal behaviour: for each line, only the content after the last \r is kept.