Strip the `<>` cursor marker from PHP source and return the cleaned content along with the cursor's line and character position.
(source: &str)
| 321 | /// Strip the `<>` cursor marker from PHP source and return the cleaned |
| 322 | /// content along with the cursor's line and character position. |
| 323 | fn strip_cursor(source: &str) -> Result<(String, u32, u32), String> { |
| 324 | let marker_pos = source |
| 325 | .find("<>") |
| 326 | .ok_or("Fixture body missing `<>` cursor marker")?; |
| 327 | |
| 328 | let before = &source[..marker_pos]; |
| 329 | let line = before.chars().filter(|&c| c == '\n').count() as u32; |
| 330 | let last_newline = before.rfind('\n').map(|i| i + 1).unwrap_or(0); |
| 331 | let char = before[last_newline..].len() as u32; |
| 332 | |
| 333 | let mut cleaned = String::with_capacity(source.len() - 2); |
| 334 | cleaned.push_str(before); |
| 335 | cleaned.push_str(&source[marker_pos + 2..]); |
| 336 | |
| 337 | Ok((cleaned, line, char)) |
| 338 | } |
| 339 | |
| 340 | // ─── Test execution ───────────────────────────────────────────────────────── |
| 341 |
no test coverage detected