diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-04-12 20:37:01 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-04-12 20:37:01 +0800 |
| commit | 40578ba8e008e69d8fa0615a822b286617f37adb (patch) | |
| tree | 545fa64e5999d9ab0e17d5f13c4e771d9f92d934 /mingling_core/src | |
| parent | 7a51b02771110251cf120cd4d85be8082c59ef1a (diff) | |
Add Windows-specific flag detection and improve PowerShell completion
Diffstat (limited to 'mingling_core/src')
| -rw-r--r-- | mingling_core/src/asset/comp/shell_ctx.rs | 19 |
1 files changed, 16 insertions, 3 deletions
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. |
