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

Function detect_line_indent

src/code_actions/extract_function.rs:830–835  ·  view source on GitHub ↗

Detect the indentation of the line containing the given offset. Returns only the leading whitespace of that line, without adding an extra indent level.

(content: &str, offset: usize)

Source from the content-addressed store, hash-verified

828/// Returns only the leading whitespace of that line, without adding
829/// an extra indent level.
830fn detect_line_indent(content: &str, offset: usize) -> String {
831 let before = &content[..offset];
832 let line_start = before.rfind('\n').map_or(0, |p| p + 1);
833 let line = &content[line_start..offset];
834 line.chars().take_while(|c| c.is_whitespace()).collect()
835}
836
837/// Detect whether the file uses tabs or spaces (and how many spaces).
838fn detect_indent_unit(content: &str) -> &str {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected