fix: completion path with ctx.leaf (#282)

This commit is contained in:
Myriad-Dreamin 2024-05-13 21:41:12 +08:00 committed by GitHub
parent c90a766fdc
commit 04dd06313a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -740,7 +740,7 @@ fn type_completion(
let source = ctx.ctx.source_by_id(ctx.root.span().id()?).ok()?;
ctx.completions2.extend(
complete_path(ctx.ctx, None, &source, ctx.cursor, p)
complete_path(ctx.ctx, Some(ctx.leaf.clone()), &source, ctx.cursor, p)
.into_iter()
.flatten(),
);
@ -1084,6 +1084,7 @@ pub fn complete_path(
let is_in_text;
let text;
let rng;
let v = v.filter(|v| v.kind() == SyntaxKind::Str);
if let Some(v) = v {
// todo: the non-str case
v.cast::<ast::Str>()?;
@ -1109,6 +1110,7 @@ pub fn complete_path(
rng = cursor..cursor;
is_in_text = false;
}
log::info!("complete_path: is_in_text: {is_in_text:?}");
let path = Path::new(text.as_str());
let has_root = path.has_root();