fix(vterm): +vterm/toggle creating duplicates
If vterm-buffer-name-string is set to non-nil, then vterm will rename the buffer after it is initialized. Since +vterm/toggle looks up buffers by name, it will lose track of them, causing it to create a new one on each invocation. With this, it will no longer lose track of them. Fix: #6651
This commit is contained in:
parent
4cf5ae8be1
commit
a0a4aa81c1
1 changed files with 9 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
;;; term/vterm/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +vterm--id nil)
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm/toggle (arg)
|
||||
"Toggles a terminal popup window at project root.
|
||||
|
@ -27,8 +29,13 @@ Returns the vterm buffer."
|
|||
(delete-window window))))
|
||||
(if-let (win (get-buffer-window buffer-name))
|
||||
(delete-window win)
|
||||
(let ((buffer (get-buffer-create buffer-name)))
|
||||
(let ((buffer (or (cl-loop for buf in (doom-buffers-in-mode 'vterm-mode)
|
||||
if (equal (buffer-local-value '+vterm--id buf)
|
||||
buffer-name)
|
||||
return buf)
|
||||
(get-buffer-create buffer-name))))
|
||||
(with-current-buffer buffer
|
||||
(setq-local +vterm--id buffer-name)
|
||||
(unless (eq major-mode 'vterm-mode)
|
||||
(vterm-mode)))
|
||||
(pop-to-buffer buffer)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue