From 5e10b03acb0312155d0d76e06d366bcf76cb9f27 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 12 Apr 2026 00:22:28 +0800 Subject: Filter out __comp node and improve debug logging in completion helper --- mingling_core/src/asset/comp.rs | 27 ++++++++++++++++----------- 1 file 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 @@ -112,36 +112,41 @@ impl CompletionHelper { } fn default_completion
(ctx: &ShellContext) -> Suggest
-where
- P: ProgramCollect (ctx)
-}
-
-fn try_comp_cmd_nodes (ctx: &ShellContext) -> Suggest
where
P: ProgramCollect ()
.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()
--
cgit