From 40578ba8e008e69d8fa0615a822b286617f37adb Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Sun, 12 Apr 2026 20:37:01 +0800 Subject: Add Windows-specific flag detection and improve PowerShell completion --- mingling_core/src/asset/comp/shell_ctx.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'mingling_core/src') diff --git a/mingling_core/src/asset/comp/shell_ctx.rs b/mingling_core/src/asset/comp/shell_ctx.rs index e5d095c..dd2aa86 100644 --- a/mingling_core/src/asset/comp/shell_ctx.rs +++ b/mingling_core/src/asset/comp/shell_ctx.rs @@ -175,8 +175,14 @@ impl ShellContext { /// /// This method determines whether the current word being typed starts with /// a dash (`-`), indicating that the user is likely in the process of - /// entering a command-line flag. It returns `true` if the current word - /// begins with a dash character. + /// entering a command-line flag. On Windows, an empty current word is also + /// considered as typing a flag to accommodate shell behavior differences. + /// It returns `true` if the current word begins with a dash character. + /// + /// # Platform-specific behavior + /// + /// - **Windows**: Returns `true` if `current_word` is empty or starts with `-` + /// - **Other platforms**: Returns `true` only if `current_word` starts with `-` /// /// # Example /// @@ -197,7 +203,14 @@ impl ShellContext { /// } /// ``` pub fn typing_argument(&self) -> bool { - self.current_word.starts_with("-") + #[cfg(target_os = "windows")] + { + self.current_word.is_empty() + } + #[cfg(not(target_os = "windows"))] + { + self.current_word.starts_with("-") + } } /// Filters out already typed flag arguments from suggestion results. -- cgit