summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useSlashCompletion.tsx
diff options
context:
space:
mode:
authorSandy Tao <[email protected]>2025-08-04 10:49:15 -0700
committerGitHub <[email protected]>2025-08-04 17:49:15 +0000
commitb9fe4fc263340c7a614e3e36462284b865e641c7 (patch)
tree30676821ed0ba9378af060c68197dfc2a268252e /packages/cli/src/ui/hooks/useSlashCompletion.tsx
parente506b40c271da0e05a361f5299c37976a9e1f1f3 (diff)
feat(cli): Handle Punctuation in @ Command Parsing (#5482)
Diffstat (limited to 'packages/cli/src/ui/hooks/useSlashCompletion.tsx')
-rw-r--r--packages/cli/src/ui/hooks/useSlashCompletion.tsx13
1 files changed, 10 insertions, 3 deletions
diff --git a/packages/cli/src/ui/hooks/useSlashCompletion.tsx b/packages/cli/src/ui/hooks/useSlashCompletion.tsx
index f68d52d8..c6821358 100644
--- a/packages/cli/src/ui/hooks/useSlashCompletion.tsx
+++ b/packages/cli/src/ui/hooks/useSlashCompletion.tsx
@@ -16,6 +16,7 @@ import {
Config,
FileDiscoveryService,
DEFAULT_FILE_FILTERING_OPTIONS,
+ SHELL_SPECIAL_CHARS,
} from '@google/gemini-cli-core';
import { Suggestion } from '../components/SuggestionsDisplay.js';
import { CommandContext, SlashCommand } from '../commands/types.js';
@@ -513,11 +514,17 @@ export function useSlashCompletion(
];
}
- // Like glob, we always return forwardslashes, even in windows.
+ // Like glob, we always return forward slashes for path separators, even on Windows.
+ // But preserve backslash escaping for special characters.
+ const specialCharsLookahead = `(?![${SHELL_SPECIAL_CHARS.source.slice(1, -1)}])`;
+ const pathSeparatorRegex = new RegExp(
+ `\\\\${specialCharsLookahead}`,
+ 'g',
+ );
fetchedSuggestions = fetchedSuggestions.map((suggestion) => ({
...suggestion,
- label: suggestion.label.replace(/\\/g, '/'),
- value: suggestion.value.replace(/\\/g, '/'),
+ label: suggestion.label.replace(pathSeparatorRegex, '/'),
+ value: suggestion.value.replace(pathSeparatorRegex, '/'),
}));
// Sort by depth, then directories first, then alphabetically