Alexander-Miller / treemacs

GNU General Public License v3.0
2.12k stars 155 forks source link

treemacs-project-follow-mode and treemacs-follow-mode focusing to the project root rather than an open file when sidebar shown #1035

Closed iamkarlson closed 1 year ago

iamkarlson commented 1 year ago

Whenever sidebar is open with treemacs-toggle it's always focusing on the root of the project, rather than the currently open file. image

It immediately sync once I navigate to the buffer but it means that whenever I open treemacs, I have to jump back and forth to make follow-mode works

Alexander-Miller commented 1 year ago

Whenever sidebar is open with treemacs-toggle it's always focusing on the root of the project, rather than the currently open file.

I don't seem to be able to reproduce that locally. In addition there is no treemacs-toggle command. You either mean something else, or it's a doom feature. I know that doom makes some additions to treemacs, and that it also pins the versions of its module dependencies.

So first we need to see if this has something to do with doom - can you still reproduce this bug when you install the latest version of treemacs as a normal package, and not a doom module? And if yes, what exactly are the steps to reproduce it, and what does your config look like?

iamkarlson commented 1 year ago

You're right, with treemacs command it works fine. Doom has indeed a helper function that is called +treemacs-toggle and it's defined like this:

;;;###autoload
(defun +treemacs/toggle ()
  "Initialize or toggle treemacs.

Ensures that only the current project is present and all other projects have
been removed.

Use `treemacs' command for old functionality."
  (interactive)
  (require 'treemacs)
  (pcase (treemacs-current-visibility)
    (`visible (delete-window (treemacs-get-local-window)))
    (_ (if (doom-project-p)
           (treemacs-add-and-display-current-project)
         (treemacs)))))

I will make an issue to doomemacs. Thanks!