dev: don't do complete on definition itself (#135)

* dev: don't do completion on definition itself.

* dev: update snapshot hash
This commit is contained in:
Myriad-Dreamin 2024-03-30 21:09:06 +08:00 committed by GitHub
parent 36536bbc6b
commit f7fd47d62c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View file

@ -83,6 +83,17 @@ impl StatefulRequest for CompletionRequest {
let node = root.leaf_at(cursor);
let deref_target = node.and_then(|node| get_deref_target(node, cursor));
if let Some(d) = &deref_target {
let node = d.node();
// skip if is the let binding item, todo, check whether the pattern is exact
if matches!(
node.parent_kind(),
Some(SyntaxKind::LetBinding | SyntaxKind::Closure)
) {
return None;
}
}
let mut match_ident = None;
let mut completion_result = None;
match deref_target {
@ -184,7 +195,7 @@ fn complete_path(
if !compl_path.is_dir() {
compl_path = compl_path.parent().unwrap_or(Path::new(""));
}
log::info!("compl_path: {src_path:?} + {path:?} -> {compl_path:?}");
log::debug!("compl_path: {src_path:?} + {path:?} -> {compl_path:?}");
if compl_path.is_absolute() {
log::warn!("absolute path completion is not supported for security consideration {path:?}");
@ -192,7 +203,7 @@ fn complete_path(
}
let dirs = ctx.analysis.root.join(compl_path);
log::info!("compl_dirs: {dirs:?}");
log::debug!("compl_dirs: {dirs:?}");
// find directory or files in the path
let mut folder_completions = vec![];
let mut module_completions = vec![];
@ -231,7 +242,7 @@ fn complete_path(
let w = pathdiff::diff_paths(&path, base)?;
unix_slash(&w).into()
};
log::info!("compl_label: {label:?}");
log::debug!("compl_label: {label:?}");
if path.is_dir() {
folder_completions.push(Completion {
@ -286,7 +297,7 @@ fn complete_path(
..Default::default()
};
log::info!("compl_res: {res:?}");
log::debug!("compl_res: {res:?}");
res
})

View file

@ -375,7 +375,7 @@ fn e2e() {
});
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
insta::assert_snapshot!(hash, @"siphash128_13:31d9406095865c1f57603564405d0ec2");
insta::assert_snapshot!(hash, @"siphash128_13:ce75b72cb95e2b46e0aa64da02b6ef50");
}
{