Use find in indent detection (#11650)

This commit is contained in:
Charlie Marsh 2024-05-31 16:35:19 -04:00 committed by GitHub
parent 1ad5f9c038
commit 91a5fdee7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -106,13 +106,7 @@ fn detect_indention(tokens: &[LexResult], locator: &Locator) -> Indentation {
}
TokenKind::NonLogicalNewline => {
let line = locator.line(range.end());
let indent_index = line.char_indices().find_map(|(i, c)| {
if c.is_whitespace() {
None
} else {
Some(i)
}
});
let indent_index = line.find(|c: char| !c.is_whitespace());
if let Some(indent_index) = indent_index {
if indent_index > 0 {
let whitespace = &line[..indent_index];