mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-11 07:34:22 +00:00
the offset used for the completion cursor should always be relative to the original file and not to the marco file
This commit is contained in:
parent
fbf8e12234
commit
6df969f5f4
3 changed files with 15 additions and 3 deletions
|
@ -67,7 +67,10 @@ impl SourceAnalyzer {
|
|||
let scopes = db.expr_scopes(def);
|
||||
let scope = match offset {
|
||||
None => scope_for(&scopes, &source_map, node),
|
||||
Some(offset) => scope_for_offset(db, &scopes, &source_map, node.with_value(offset)),
|
||||
Some(offset) => {
|
||||
let file_id = node.file_id.original_file(db.upcast());
|
||||
scope_for_offset(db, &scopes, &source_map, InFile::new(file_id.into(), offset))
|
||||
}
|
||||
};
|
||||
let resolver = resolver_for_scope(db.upcast(), def, scope);
|
||||
SourceAnalyzer {
|
||||
|
@ -88,7 +91,10 @@ impl SourceAnalyzer {
|
|||
let scopes = db.expr_scopes(def);
|
||||
let scope = match offset {
|
||||
None => scope_for(&scopes, &source_map, node),
|
||||
Some(offset) => scope_for_offset(db, &scopes, &source_map, node.with_value(offset)),
|
||||
Some(offset) => {
|
||||
let file_id = node.file_id.original_file(db.upcast());
|
||||
scope_for_offset(db, &scopes, &source_map, InFile::new(file_id.into(), offset))
|
||||
}
|
||||
};
|
||||
let resolver = resolver_for_scope(db.upcast(), def, scope);
|
||||
SourceAnalyzer { resolver, def: Some((def, body, source_map)), infer: None, file_id }
|
||||
|
|
|
@ -513,6 +513,7 @@ fn quux(x: i32) {
|
|||
",
|
||||
expect![[r#"
|
||||
fn quux(…) fn(i32)
|
||||
lc x i32
|
||||
ma m!(…) macro_rules! m
|
||||
bt u32
|
||||
kw crate::
|
||||
|
|
|
@ -90,11 +90,16 @@ fn x<'lt, T, const C: usize>() -> $0
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fn_return_type2() {
|
||||
fn fn_return_type_no_local_items() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() -> B$0 {
|
||||
struct Bar;
|
||||
enum Baz {}
|
||||
union Bax {
|
||||
i: i32,
|
||||
f: f32
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
|
Loading…
Reference in a new issue