the scope of the return type is not the body of the function

This commit is contained in:
XFFXFF 2022-06-16 16:12:46 +08:00
parent 519d7484f3
commit fbf8e12234
3 changed files with 30 additions and 7 deletions

View file

@ -600,13 +600,11 @@ fn scope_for_offset(
.filter(|it| it.value.kind() == SyntaxKind::MACRO_CALL)?;
Some((source.value.text_range(), scope))
})
// find containing scope
.min_by_key(|(expr_range, _scope)| {
(
!(expr_range.start() <= offset.value && offset.value <= expr_range.end()),
expr_range.len(),
)
.filter(|(expr_range, _scope)| {
expr_range.start() <= offset.value && offset.value <= expr_range.end()
})
// find containing scope
.min_by_key(|(expr_range, _scope)| expr_range.len())
.map(|(expr_range, scope)| {
adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
})