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:
XFFXFF 2022-06-16 16:43:08 +08:00
parent fbf8e12234
commit 6df969f5f4
3 changed files with 15 additions and 3 deletions

View file

@ -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 }