about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-07-19T11·16+0800
committerChris Feng <chris.w.feng@gmail.com>2016-07-19T11·16+0800
commit37e51e65ade14ded8d4a45cc725b4b66bab6b879 (patch)
tree0105b9b4ee77617200a2af7eff36a4f7f713786a
parentb409d873b6d1372dd7ba01155f7a03fb8de6e053 (diff)
Fix a workspace switch issue
* exwm-workspace.el (exwm-workspace--switch-map-nth-prefix):
Add more checking conditions.
-rw-r--r--exwm-workspace.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 551ccbfba98d..5d4d78f402ce 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -337,11 +337,17 @@ PREFIX-DIGITS is a list of the digits introduced so far."
                                   (* o x))
                                 prefix-digits)))
          (n (+ pn d))
-         (num-workspaces (exwm-workspace--count)))
-    (if (= (length prefix-digits)
-           (floor (log (1- num-workspaces) 10)))
+         prefix-length index-max index-length)
+    (if (or (= n 0)
+            (> n
+               (setq index-max (1- (exwm-workspace--count))))
+            (>= (setq prefix-length (length prefix-digits))
+                (setq index-length (floor (log index-max 10))))
+            ;; Check if it's still possible to do a match.
+            (> (* n (expt 10 (- index-length prefix-length)))
+               index-max))
         (exwm-workspace--switch-map-select-nth n)
-      ;; go ahead if there are enough digits to select any workspace.
+      ;; Go ahead if there are enough digits to select any workspace.
       (set-transient-map
        (let ((map (make-sparse-keymap))
              (cmd `(lambda ()