Skip to content

Cannot restart a terminal after killing due to retention in toggle-term--active-toggles #8

Description

@mplanchard

If I start a new terminal with something like toggle-term-eat or toggle-term-vterm, and then kill the terminal by killing both the buffer and the associated process, running toggle-term again will open an empty buffer with no running terminal.

I have tracked this down to the terminal's presence in toggle-term--active-toggles. If I set that to nil prior to running toggle-term again, it pops open a new terminal.

My workaround locally is to run essentially this set of logic before calling toggle-term-eat or whatever:

(defun my/toggle-eat-project ()
  (interactive)
  (let*
      ;; override eat with eat-project so it opens in the project root
      ((eat #'eat-project)
       (term-popup-name
        (format "%s-eat-popup"
                (or (when
                        (project-current)
                      (project-name (project-current)))
                    "global")))
       (tt-last (toggle-term--get-last-used))
       (tt-name (format " *%s*" term-popup-name))
       (tt-is-last (and tt-last (string= tt-name (car tt-last))))
       (tt-buffer (and tt-is-last (get-buffer tt-name))))
    (when (and tt-is-last (not tt-buffer))
      (setq toggle-term--active-toggles (cdr toggle-term--active-toggles)))
    (funcall-interactively 'toggle-term-find term-popup-name "eat")))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions