Skip to content

Commit 8c9def0

Browse files
committed
fix: handle exit/quit with arguments and normalize case
1 parent 7a4f509 commit 8c9def0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/cli/src/ui/hooks/slashCommandProcessor.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ export const useSlashCommandProcessor = (
321321
}
322322

323323
const trimmed = rawQuery.trim();
324-
const isExitOrQuit = ['exit', 'quit'].includes(trimmed.toLowerCase());
324+
const parts = trimmed.split(/\s+/);
325+
const commandWord = parts[0].toLowerCase();
326+
const isExitOrQuit = commandWord === 'exit' || commandWord === 'quit';
325327
if (
326328
!trimmed.startsWith('/') &&
327329
!trimmed.startsWith('?') &&
@@ -341,7 +343,15 @@ export const useSlashCommandProcessor = (
341343
}
342344

343345
let hasError = false;
344-
const commandToParse = isExitOrQuit ? `/${trimmed}` : trimmed;
346+
let commandToParse = trimmed;
347+
if (
348+
isExitOrQuit &&
349+
!trimmed.startsWith('/') &&
350+
!trimmed.startsWith('?')
351+
) {
352+
parts[0] = commandWord;
353+
commandToParse = `/${parts.join(' ')}`;
354+
}
345355
const {
346356
commandToExecute,
347357
args,

0 commit comments

Comments
 (0)