mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 10:18:16 +00:00
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:
parent
36536bbc6b
commit
f7fd47d62c
2 changed files with 16 additions and 5 deletions
|
@ -83,6 +83,17 @@ impl StatefulRequest for CompletionRequest {
|
||||||
let node = root.leaf_at(cursor);
|
let node = root.leaf_at(cursor);
|
||||||
let deref_target = node.and_then(|node| get_deref_target(node, 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 match_ident = None;
|
||||||
let mut completion_result = None;
|
let mut completion_result = None;
|
||||||
match deref_target {
|
match deref_target {
|
||||||
|
@ -184,7 +195,7 @@ fn complete_path(
|
||||||
if !compl_path.is_dir() {
|
if !compl_path.is_dir() {
|
||||||
compl_path = compl_path.parent().unwrap_or(Path::new(""));
|
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() {
|
if compl_path.is_absolute() {
|
||||||
log::warn!("absolute path completion is not supported for security consideration {path:?}");
|
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);
|
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
|
// find directory or files in the path
|
||||||
let mut folder_completions = vec![];
|
let mut folder_completions = vec![];
|
||||||
let mut module_completions = vec![];
|
let mut module_completions = vec![];
|
||||||
|
@ -231,7 +242,7 @@ fn complete_path(
|
||||||
let w = pathdiff::diff_paths(&path, base)?;
|
let w = pathdiff::diff_paths(&path, base)?;
|
||||||
unix_slash(&w).into()
|
unix_slash(&w).into()
|
||||||
};
|
};
|
||||||
log::info!("compl_label: {label:?}");
|
log::debug!("compl_label: {label:?}");
|
||||||
|
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
folder_completions.push(Completion {
|
folder_completions.push(Completion {
|
||||||
|
@ -286,7 +297,7 @@ fn complete_path(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
log::info!("compl_res: {res:?}");
|
log::debug!("compl_res: {res:?}");
|
||||||
|
|
||||||
res
|
res
|
||||||
})
|
})
|
||||||
|
|
|
@ -375,7 +375,7 @@ fn e2e() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
|
let hash = replay_log(&tinymist_binary, &root.join("neovim"));
|
||||||
insta::assert_snapshot!(hash, @"siphash128_13:31d9406095865c1f57603564405d0ec2");
|
insta::assert_snapshot!(hash, @"siphash128_13:ce75b72cb95e2b46e0aa64da02b6ef50");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue