summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/atCommandProcessor.ts
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/atCommandProcessor.ts
parente506b40c271da0e05a361f5299c37976a9e1f1f3 (diff)
feat(cli): Handle Punctuation in @ Command Parsing (#5482)
Diffstat (limited to 'packages/cli/src/ui/hooks/atCommandProcessor.ts')
-rw-r--r--packages/cli/src/ui/hooks/atCommandProcessor.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.ts b/packages/cli/src/ui/hooks/atCommandProcessor.ts
index 7b9005fa..165b7b30 100644
--- a/packages/cli/src/ui/hooks/atCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/atCommandProcessor.ts
@@ -87,9 +87,17 @@ function parseAllAtCommands(query: string): AtCommandPart[] {
inEscape = false;
} else if (char === '\\') {
inEscape = true;
- } else if (/\s/.test(char)) {
- // Path ends at first whitespace not escaped
+ } else if (/[,\s;!?()[\]{}]/.test(char)) {
+ // Path ends at first whitespace or punctuation not escaped
break;
+ } else if (char === '.') {
+ // For . we need to be more careful - only terminate if followed by whitespace or end of string
+ // This allows file extensions like .txt, .js but terminates at sentence endings like "file.txt. Next sentence"
+ const nextChar =
+ pathEndIndex + 1 < query.length ? query[pathEndIndex + 1] : '';
+ if (nextChar === '' || /\s/.test(nextChar)) {
+ break;
+ }
}
pathEndIndex++;
}
@@ -320,8 +328,7 @@ export async function handleAtCommand({
if (
i > 0 &&
initialQueryText.length > 0 &&
- !initialQueryText.endsWith(' ') &&
- resolvedSpec
+ !initialQueryText.endsWith(' ')
) {
// Add space if previous part was text and didn't end with space, or if previous was @path
const prevPart = commandParts[i - 1];