aboutsummaryrefslogtreecommitdiff
path: root/mingling_core
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-12 00:22:28 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-12 00:22:28 +0800
commit5e10b03acb0312155d0d76e06d366bcf76cb9f27 (patch)
treedc291394f61932a04c5e867b1477830bfe6146e8 /mingling_core
parentc15c257af64a67e533258f419382668918f99607 (diff)
Filter out __comp node and improve debug logging in completion helper
Diffstat (limited to 'mingling_core')
-rw-r--r--mingling_core/src/asset/comp.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/mingling_core/src/asset/comp.rs b/mingling_core/src/asset/comp.rs
index 40482fd..c2e6970 100644
--- a/mingling_core/src/asset/comp.rs
+++ b/mingling_core/src/asset/comp.rs
@@ -115,33 +115,38 @@ fn default_completion<P>(ctx: &ShellContext) -> Suggest
where
P: ProgramCollect<Enum = P> + Display + 'static,
{
- try_comp_cmd_nodes::<P>(ctx)
-}
-
-fn try_comp_cmd_nodes<P>(ctx: &ShellContext) -> Suggest
-where
- P: ProgramCollect<Enum = P> + Display + 'static,
-{
let cmd_nodes: Vec<String> = this::<P>()
.get_nodes()
.into_iter()
+ .filter(|(s, _)| s != "__comp")
.map(|(s, _)| s)
.collect();
+ debug!("cmd_nodes: {:?}", cmd_nodes);
// If the current position is less than 1, do not perform completion
if ctx.word_index < 1 {
+ debug!("word_index < 1, returning file suggestions");
return file_suggest();
};
// Get the current input path
- let input_path: Vec<&str> = ctx.all_words[1..ctx.word_index]
+ debug!(
+ "input_path before filter: {:?}",
+ &ctx.all_words.get(1..ctx.word_index).unwrap_or(&[])
+ );
+
+ let input_path: Vec<&str> = ctx
+ .all_words
+ .get(1..ctx.word_index)
+ .unwrap_or(&[])
.iter()
.filter(|s| !s.is_empty())
.map(|s| s.as_str())
.collect();
+ debug!("input_path after filter: {:?}", input_path);
debug!(
- "try_comp_cmd_nodes: input_path = {:?}, word_index = {}, all_words = {:?}",
+ "default_completion: input_path = {:?}, word_index = {}, all_words = {:?}",
input_path, ctx.word_index, ctx.all_words
);
@@ -178,7 +183,7 @@ where
suggestions.sort();
suggestions.dedup();
debug!(
- "try_comp_cmd_nodes: current word suggestions = {:?}",
+ "default_completion: current word suggestions = {:?}",
suggestions
);
return suggestions.into();
@@ -229,7 +234,7 @@ where
suggestions.sort();
suggestions.dedup();
- debug!("try_comp_cmd_nodes: suggestions = {:?}", suggestions);
+ debug!("default_completion: suggestions = {:?}", suggestions);
if suggestions.is_empty() {
file_suggest()