MCPcopy Index your code
hub / github.com/PHPantom-dev/phpantom_lsp / strip_cursor

Function strip_cursor

tests/fixture_runner.rs:323–338  ·  view source on GitHub ↗

Strip the `<>` cursor marker from PHP source and return the cleaned content along with the cursor's line and character position.

(source: &str)

Source from the content-addressed store, hash-verified

321/// Strip the `<>` cursor marker from PHP source and return the cleaned
322/// content along with the cursor's line and character position.
323fn 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

Callers 2

parse_single_file_bodyFunction · 0.70
parse_multi_file_bodyFunction · 0.70

Calls 4

filterMethod · 0.80
findMethod · 0.45
countMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected