about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-09-05T11·40+0100
committertazjin <mail@tazj.in>2020-09-05T11·45+0000
commit11430f4a4b3d4b2f6cfc103e574768dbcc64b517 (patch)
treec2d2476ef8b9fe755371d896c860e9f8d9906f67 /tools
parent67e8f477a1f02195228732a643d5dfce8e21caa7 (diff)
fix(term-switcher.el): Explicitly fail if buffers are missing r/1763
Since upgrading to Emacs 27 I have observed a strange behaviour where
this terminal switcher sometimes fails to select a valid buffer, in
which case it falls through to the case that just opens a new buffer
instead.

This is kind of annoying and to aid in debugging this change makes the
creation of new buffers explicit and fails if no matching buffer is
found.

Note that this is likely not a fix for the issue itself, but it will
help debug what is going on.

Change-Id: I906869aba7d25156aaf92c090b169ce02785b85e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1930
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs-pkgs/term-switcher/term-switcher.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/emacs-pkgs/term-switcher/term-switcher.el b/tools/emacs-pkgs/term-switcher/term-switcher.el
index 67595474fa..0055f87fd6 100644
--- a/tools/emacs-pkgs/term-switcher/term-switcher.el
+++ b/tools/emacs-pkgs/term-switcher/term-switcher.el
@@ -29,10 +29,11 @@
 (defun ts/open-or-create-vterm (buffer-name)
   "Switch to the buffer with BUFFER-NAME or create a new vterm
   buffer."
-  (let ((buffer (get-buffer buffer-name)))
-    (if (not buffer)
-        (vterm)
-      (switch-to-buffer buffer))))
+  (if (equal "New vterm" buffer-name)
+      (vterm)
+    (if-let ((buffer (get-buffer buffer-name)))
+        (switch-to-buffer buffer)
+      (error "Could not find vterm buffer: %s" buffer-name))))
 
 (defun ts/is-vterm-buffer (buffer)
   "Determine whether BUFFER runs a vterm."