From d158736c4548940dad6a0b15751b79325bf99d88 Mon Sep 17 00:00:00 2001 From: Hellow2 Date: Thu, 30 Mar 2023 10:34:17 +0200 Subject: [PATCH] pixed bug regarding the maths of choosing one index --- src/music_kraken/pages/download_center/search.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/music_kraken/pages/download_center/search.py b/src/music_kraken/pages/download_center/search.py index 73eaac5..4b17493 100644 --- a/src/music_kraken/pages/download_center/search.py +++ b/src/music_kraken/pages/download_center/search.py @@ -68,16 +68,16 @@ class MultiPageOptions: for key in self._current_option_dict: return self.choose_from_single_page(key, index), key - j = 0 + sum_of_length = 0 for page, options in self._current_option_dict.items(): - option_len = len(options) - if option_len > self.max_displayed_options: - option_len = self.max_displayed_options + option_len = min((len(options), self.max_displayed_options)) - if j <= index < j + option_len: - return options[j + option_len - 1], page + index_of_list = index - sum_of_length + + if index_of_list < option_len: + return options[index_of_list], page - j += option_len + sum_of_length += option_len raise IndexError("index is out of range")