MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / flush_buffer

Function flush_buffer

src/blade/preprocessor.rs:399–431  ·  view source on GitHub ↗
(
    processed: &mut String,
    buffer: &mut String,
    mode: Mode,
    current_utf16_col: u32,
    adjustments: &mut Vec<(u32, u32)>,
)

Source from the content-addressed store, hash-verified

397}
398
399fn 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
433fn utf16_count(s: &str) -> usize {
434 s.encode_utf16().count()

Callers 1

preprocessFunction · 0.85

Calls 3

utf16_countFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected