better comparison

This commit is contained in:
Jeroen Vannevel 2022-02-01 09:00:30 +00:00
parent b290285dd8
commit 1811f6330b
No known key found for this signature in database
GPG Key ID: 78EF5F52F38C49BD

View File

@ -482,9 +482,7 @@ fn from_range(parent: ast::StmtList, selected: TextRange) -> FunctionBody {
let full_body = parent.syntax().children_with_tokens(); let full_body = parent.syntax().children_with_tokens();
let mut text_range = full_body let mut text_range = full_body
.filter(|it| { .filter(|it| ast::Stmt::can_cast(it.kind()) || it.kind() == COMMENT)
matches!(it.kind().is_punct() || it.kind() == SyntaxKind::WHITESPACE, false)
})
.map(|element| element.text_range()) .map(|element| element.text_range())
.filter(|&range| selected.intersect(range).filter(|it| !it.is_empty()).is_some()) .filter(|&range| selected.intersect(range).filter(|it| !it.is_empty()).is_some())
.reduce(|acc, stmt| acc.cover(stmt)); .reduce(|acc, stmt| acc.cover(stmt));