diff options
Diffstat (limited to 'solo-tool-project/src/solo_tool/handlers.py')
-rw-r--r-- | solo-tool-project/src/solo_tool/handlers.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/solo-tool-project/src/solo_tool/handlers.py b/solo-tool-project/src/solo_tool/handlers.py index b178b3a..1820e86 100644 --- a/solo-tool-project/src/solo_tool/handlers.py +++ b/solo-tool-project/src/solo_tool/handlers.py @@ -56,14 +56,15 @@ def keyPointAbsolute(st: SoloTool, kp: float) -> Callable[[], None]: def keyPointRelative(st: SoloTool, delta: int) -> Callable[[], None]: from bisect import bisect_right, bisect_left def f(): + l = sorted(set(st.keyPoints + [st.keyPoint])) if delta > 0: - pivot = bisect_right(st.keyPoints, st.keyPoint) - 1 + pivot = bisect_right(l, st.keyPoint) - 1 elif delta < 0: - pivot = bisect_left(st.keyPoints, st.keyPoint) - 1 + pivot = bisect_left(l, st.keyPoint) else: return - new = max(min(pivot + delta, len(st.keyPoints) - 1), 0) - st.keyPoint = st.keyPoints[new] + new = max(min(pivot + delta, len(l) - 1), 0) + st.keyPoint = l[new] return f def rateAbsolute(st: SoloTool, value: float) -> Callable[[], None]: |