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)
```
This commit is contained in:
Jackie Li 2024-01-18 09:53:47 +00:00
parent 7826fefe30
commit 0d3c5497ff
No known key found for this signature in database
GPG Key ID: 9D44BB781C299FEF

View File

@ -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: