@@ -558,11 +558,11 @@ export const App = ({
558558 function selectCurrent ( ) {
559559 const selected = slashMatches [ slashSelectedIndex ] ?? slashMatches [ 0 ]
560560 if ( ! selected ) {
561- return true
561+ return
562562 }
563563 const startIndex = slashContext . startIndex
564564 if ( startIndex < 0 ) {
565- return true
565+ return
566566 }
567567 const before = helpers . value . slice ( 0 , startIndex )
568568 const after = helpers . value . slice (
@@ -577,18 +577,21 @@ export const App = ({
577577 }
578578
579579 if ( key . name === 'down' && ! hasModifier ) {
580+ // Move down (no wrap)
580581 setSlashSelectedIndex ( ( prev ) =>
581582 Math . min ( prev + 1 , slashMatches . length - 1 ) ,
582583 )
583584 return true
584585 }
585586
586587 if ( key . name === 'up' && ! hasModifier ) {
588+ // Move up (no wrap)
587589 setSlashSelectedIndex ( ( prev ) => Math . max ( prev - 1 , 0 ) )
588590 return true
589591 }
590592
591593 if ( key . name === 'tab' && key . shift && ! hasModifier ) {
594+ // Move up with wrap
592595 setSlashSelectedIndex (
593596 ( prev ) => ( slashMatches . length + prev - 1 ) % slashMatches . length ,
594597 )
@@ -597,6 +600,7 @@ export const App = ({
597600
598601 if ( key . name === 'tab' && ! key . shift && ! hasModifier ) {
599602 if ( slashMatches . length > 1 ) {
603+ // Move up with wrap
600604 setSlashSelectedIndex ( ( prev ) => ( prev + 1 ) % slashMatches . length )
601605 } else {
602606 selectCurrent ( )
@@ -639,11 +643,11 @@ export const App = ({
639643 function selectCurrent ( ) {
640644 const selected = agentMatches [ agentSelectedIndex ] ?? agentMatches [ 0 ]
641645 if ( ! selected ) {
642- return true
646+ return
643647 }
644648 const startIndex = mentionContext . startIndex
645649 if ( startIndex < 0 ) {
646- return true
650+ return
647651 }
648652
649653 const before = helpers . value . slice ( 0 , startIndex )
@@ -659,18 +663,21 @@ export const App = ({
659663 }
660664
661665 if ( key . name === 'down' && ! hasModifier ) {
666+ // Move down (no wrap)
662667 setAgentSelectedIndex ( ( prev ) =>
663668 Math . min ( prev + 1 , agentMatches . length - 1 ) ,
664669 )
665670 return true
666671 }
667672
668673 if ( key . name === 'up' && ! hasModifier ) {
674+ // Move up (no wrap)
669675 setAgentSelectedIndex ( ( prev ) => Math . max ( prev - 1 , 0 ) )
670676 return true
671677 }
672678
673679 if ( key . name === 'tab' && key . shift && ! hasModifier ) {
680+ // Move up with wrap
674681 setAgentSelectedIndex (
675682 ( prev ) => ( agentMatches . length + prev - 1 ) % agentMatches . length ,
676683 )
@@ -679,6 +686,7 @@ export const App = ({
679686
680687 if ( key . name === 'tab' && ! key . shift && ! hasModifier ) {
681688 if ( agentMatches . length > 1 ) {
689+ // Move down with wrap
682690 setAgentSelectedIndex ( ( prev ) => ( prev + 1 ) % agentMatches . length )
683691 } else {
684692 selectCurrent ( )
0 commit comments