@@ -72,19 +72,70 @@ await PersistLearnSettingsAsync(settings => settings with
7272 }
7373
7474 private async Task StepRsvpWordAsync ( int delta )
75+ {
76+ await StepRsvpToIndexAsync ( _currentIndex + delta ) ;
77+ }
78+
79+ private async Task StepRsvpToIndexAsync ( int index )
7580 {
7681 if ( _timeline . Count == 0 )
7782 {
7883 return ;
7984 }
8085
81- _currentIndex = ResolveNavigationIndex ( _currentIndex + delta ) ;
86+ _currentIndex = ResolveNavigationIndex ( index ) ;
8287 UpdateDisplayedState ( ) ;
8388 RestartPlaybackLoopIfActive ( ) ;
8489 await InvokeAsync ( StateHasChanged ) ;
8590 await AwaitPendingFocusLayoutSyncAsync ( ) ;
8691 }
8792
93+ private int ResolveCurrentPhraseStartIndex ( )
94+ {
95+ if ( _timeline . Count == 0 )
96+ {
97+ return 0 ;
98+ }
99+
100+ var currentEntry = _timeline [ Math . Clamp ( _currentIndex , 0 , _timeline . Count - 1 ) ] ;
101+ return currentEntry . SentenceStartIndex ;
102+ }
103+
104+ private int ResolveNextPhraseIndex ( )
105+ {
106+ if ( _timeline . Count == 0 )
107+ {
108+ return 0 ;
109+ }
110+
111+ var currentEntry = _timeline [ Math . Clamp ( _currentIndex , 0 , _timeline . Count - 1 ) ] ;
112+ return currentEntry . SentenceEndIndex + 1 ;
113+ }
114+
115+ private int ResolvePreviousPhraseIndex ( )
116+ {
117+ if ( _timeline . Count == 0 )
118+ {
119+ return 0 ;
120+ }
121+
122+ var currentEntry = _timeline [ Math . Clamp ( _currentIndex , 0 , _timeline . Count - 1 ) ] ;
123+ if ( _currentIndex > currentEntry . SentenceStartIndex )
124+ {
125+ return currentEntry . SentenceStartIndex ;
126+ }
127+
128+ var previousIndex = currentEntry . SentenceStartIndex - 1 ;
129+ if ( previousIndex < 0 )
130+ {
131+ return _isLoopEnabled
132+ ? _timeline [ ^ 1 ] . SentenceStartIndex
133+ : 0 ;
134+ }
135+
136+ return _timeline [ previousIndex ] . SentenceStartIndex ;
137+ }
138+
88139 private void RestartPlaybackLoopIfActive ( )
89140 {
90141 if ( _isPlaying )
0 commit comments