aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-10 01:18:25 +0200
committersalmonik <raisersoft@proton.me>2026-05-10 01:18:25 +0200
commitc751add94e265e12f590674fc0673787c4ca87c8 (patch)
treec3401443d2286bcb6683ff9460a18e91a4a4f732 /src
parentFix album shuffle - shuffle tracks when adding in album mode (diff)
downloadrsplayer-c751add94e265e12f590674fc0673787c4ca87c8.tar.gz
rsplayer-c751add94e265e12f590674fc0673787c4ca87c8.zip
Fix shuffle to not shuffle current track - only shuffle tracks after current position
Diffstat (limited to 'src')
-rw-r--r--src/queue.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/queue.rs b/src/queue.rs
index 503560b..2c20356 100644
--- a/src/queue.rs
+++ b/src/queue.rs
@@ -227,9 +227,7 @@ impl Queue {
227 ShuffleMode::All => { 227 ShuffleMode::All => {
228 let mut rng = rand::rng(); 228 let mut rng = rand::rng();
229 let pos = self.position.min(len.saturating_sub(1)); 229 let pos = self.position.min(len.saturating_sub(1));
230 if pos == 0 && len > 1 { 230 if pos + 1 < len {
231 self.shuffled_indices.shuffle(&mut rng);
232 } else if pos + 1 < len {
233 self.shuffled_indices[pos + 1..].shuffle(&mut rng); 231 self.shuffled_indices[pos + 1..].shuffle(&mut rng);
234 } 232 }
235 } 233 }
@@ -244,13 +242,12 @@ impl Queue {
244 let len = self.tracks.len(); 242 let len = self.tracks.len();
245 self.shuffled_indices = (0..len).collect(); 243 self.shuffled_indices = (0..len).collect();
246 244
247 let mut rng = rand::rng(); 245 if len > 1 {
248 let pos = self.position.min(len.saturating_sub(1)); 246 let mut rng = rand::rng();
249 247 let pos = self.position.min(len.saturating_sub(1));
250 if pos == 0 && len > 1 { 248 if pos + 1 < len {
251 self.shuffle_album_range(0..len, &mut rng); 249 self.shuffle_album_range(pos + 1..len, &mut rng);
252 } else if pos + 1 < len { 250 }
253 self.shuffle_album_range(pos + 1..len, &mut rng);
254 } 251 }
255 } 252 }
256 253