MCPcopy Create free account
hub / github.com/continuedev/continue / handleSlashCommandNavigation

Function handleSlashCommandNavigation

extensions/cli/src/ui/UserInput.tsx:454–500  ·  view source on GitHub ↗
(key: any)

Source from the content-addressed store, hash-verified

452 };
453
454 const handleSlashCommandNavigation = (key: any): boolean => {
455 const filteredCommands = getFilteredCommands();
456
457 if (key.upArrow) {
458 setSelectedCommandIndex((prev) =>
459 prev > 0 ? prev - 1 : filteredCommands.length - 1,
460 );
461 return true;
462 }
463
464 if (key.downArrow) {
465 setSelectedCommandIndex((prev) =>
466 prev < filteredCommands.length - 1 ? prev + 1 : 0,
467 );
468 return true;
469 }
470
471 if ((key.return && !key.shift) || key.tab) {
472 if (filteredCommands.length > 0) {
473 const commandName = filteredCommands[selectedCommandIndex].name;
474 if (key.return && commandName !== "title") {
475 // select and submit the command
476 const commandText = "/" + commandName;
477 inputHistory.addEntry(commandText);
478
479 // queue up when responding/generating
480 if (!isRemoteMode && (isWaitingForResponse || isCompacting)) {
481 void messageQueue.enqueueMessage(commandText);
482 } else {
483 onSubmit(commandText);
484 }
485
486 // reset after submitting command
487 textBuffer.clear();
488 setInputText("");
489 setCursorPosition(0);
490 setShowSlashCommands(false);
491 setShowBashMode(false);
492 } else {
493 selectSlashCommand(commandName);
494 }
495 }
496 return true;
497 }
498
499 return false;
500 };
501
502 const handleFileSearchNavigation = (key: any): boolean => {
503 if (key.upArrow) {

Callers 1

UserInputFunction · 0.85

Calls 6

getFilteredCommandsFunction · 0.85
selectSlashCommandFunction · 0.85
addEntryMethod · 0.80
enqueueMessageMethod · 0.80
onSubmitFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected