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)
| 828 | /// Returns only the leading whitespace of that line, without adding |
| 829 | /// an extra indent level. |
| 830 | fn 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). |
| 838 | fn detect_indent_unit(content: &str) -> &str { |
no outgoing calls
no test coverage detected