about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2024-09-29T00·58+0300
committerclbot <clbot@tvl.fyi>2024-09-29T01·16+0000
commit89bd07ee72bd830068e786077f25911c629bcd20 (patch)
tree4a048a24b7bf9bcde29a097318473e9ed28fa9c1
parent334f60008b6547deee70c27f040c7e0976d67a30 (diff)
fix(emacs-pkgs/niri): handle non-matching selections adequately r/8732
If the user puts in a string that doesn't match any of the selectables, do one
of the following:

1. When called inside of Emacs, create a new buffer with that name.
2. When called outside of Emacs, do nothing.

Change-Id: I92ba985b5cd7805d37d5d0e0631b20fdce7ce479
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12542
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
-rw-r--r--tools/emacs-pkgs/niri/niri.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/emacs-pkgs/niri/niri.el b/tools/emacs-pkgs/niri/niri.el
index 62c2b712cde2..32b65efdfcaa 100644
--- a/tools/emacs-pkgs/niri/niri.el
+++ b/tools/emacs-pkgs/niri/niri.el
@@ -116,8 +116,9 @@ switch Niri windows when called from outside of Emacs."
 
          (target-key (completing-read "Switch to: " (map-keys selectables)))
          (target (map-elt selectables target-key)))
-
-    (niri--target-action-internal target)))
+    (if target
+        (niri--target-action-internal target)
+      (switch-to-buffer target-key nil t))))
 
 
 (defun niri--target-action-external (target frames)
@@ -174,7 +175,7 @@ Emacsclient."
                      (insert key "\n"))
                    (call-process-region nil nil "fuzzel" t t nil "-d")
                    (string-trim (buffer-string)))))
-    (unless (string-empty-p target)
-      (niri--target-action-external (map-elt selectables target) (cdr all)))))
+    (when-let ((selectable (map-elt selectables target)))
+      (niri--target-action-external selectable (cdr all)))))
 
 (provide 'niri)