From 0d3c5497ff09a8cd8b6232c0d8df317b80f60c75 Mon Sep 17 00:00:00 2001 From: Jackie Li Date: Thu, 18 Jan 2024 09:53:47 +0000 Subject: [PATCH] for #7009 Oops, the num is already negative index, no need to reverse here. Alternatively this is shorter: ``` def nth_os_window(self, num: int = 1) -> None: if not self.os_window_map: return if num == 0: os_window_id = current_focused_os_window_id() or last_focused_os_window_id() elif num > 0: ids = tuple(self.os_window_map.keys()) os_window_id = ids[min(num, len(ids)) - 1] else: fc_map = os_window_focus_counters() ids = sorted(fc_map.keys(), key=fc_map.__getitem__, reverse=True) os_window_id = ids[min(-num, len(ids)-1)] focus_os_window(os_window_id, True) ``` --- kitty/boss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kitty/boss.py b/kitty/boss.py index 6199a16f8..6ba84f38a 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1733,7 +1733,7 @@ class Boss: focus_os_window(os_window_id, True) elif num < 0: fc_map = os_window_focus_counters() - s = sorted(fc_map.keys(), key=fc_map.__getitem__, reverse=True) + s = sorted(fc_map.keys(), key=fc_map.__getitem__) if not s: return try: