Skip to content

Offline gym log for Android. No account, no ads, no internet.

Skipping ahead in a superset stays inside the chain

InlitXd1f4366f874a
diff --git a/lib/state/workout_state.dart b/lib/state/workout_state.dart
index 9832835..f805e25 100644
--- a/lib/state/workout_state.dart
+++ b/lib/state/workout_state.dart
@@ -1137,7 +1137,14 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
void nextExercise() {
final s = session!;
- s.currentIndex = math.min(s.currentIndex + 1, s.exercises.length - 1);
+ var next = s.currentIndex + 1;
+ final chain = chainAt(s.currentIndex);
+ if (chain.length > 1) {
+ final after = chain.where((i) => i > s.currentIndex && s.exercises[i].hasUndone);
+ next = after.isNotEmpty ? after.first : chain.last + 1;
+ if (next >= s.exercises.length) next = s.currentIndex + 1;
+ }
+ s.currentIndex = math.min(next, s.exercises.length - 1);
_persist();
notifyListeners();
}