(
processed: &mut String,
buffer: &mut String,
mode: Mode,
current_utf16_col: u32,
adjustments: &mut Vec<(u32, u32)>,
)
| 397 | } |
| 398 | |
| 399 | fn flush_buffer( |
| 400 | processed: &mut String, |
| 401 | buffer: &mut String, |
| 402 | mode: Mode, |
| 403 | current_utf16_col: u32, |
| 404 | adjustments: &mut Vec<(u32, u32)>, |
| 405 | ) { |
| 406 | if buffer.is_empty() { |
| 407 | return; |
| 408 | } |
| 409 | let blade_start = current_utf16_col.saturating_sub(utf16_count(buffer) as u32); |
| 410 | |
| 411 | if mode == Mode::Html { |
| 412 | // HTML outside PHP/Directives — mask with spaces to maintain 1:1 utf-16 mapping. |
| 413 | adjustments.push((blade_start, utf16_count(processed) as u32)); |
| 414 | |
| 415 | for c in buffer.chars() { |
| 416 | let len = c.len_utf16(); |
| 417 | for _ in 0..len { |
| 418 | processed.push(' '); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | adjustments.push((current_utf16_col, utf16_count(processed) as u32)); |
| 423 | } else { |
| 424 | // PHP content — 1:1 mapping |
| 425 | adjustments.push((blade_start, utf16_count(processed) as u32)); |
| 426 | processed.push_str(buffer); |
| 427 | adjustments.push((current_utf16_col, utf16_count(processed) as u32)); |
| 428 | } |
| 429 | |
| 430 | buffer.clear(); |
| 431 | } |
| 432 | |
| 433 | fn utf16_count(s: &str) -> usize { |
| 434 | s.encode_utf16().count() |
no test coverage detected