summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/atCommandProcessor.ts
diff options
context:
space:
mode:
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];