Alexander-Miller / treemacs

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

Fringe indicator missing at startup #1111

Closed AndreasMatthias closed 4 months ago

AndreasMatthias commented 5 months ago

I'm facing a minor issue with treemacs-fringe-indicator-mode. Here is an example:

File test.el:

(require 'package)
(package-initialize)

(unless (package-installed-p 'org-extra-emphasis)
  (package-vc-install "https://github.com/QiangF/org-extra-emphasis"))
(use-package org-extra-emphasis)

(use-package treemacs-magit)

(treemacs)

After starting Emacs with

emacs -Q -l test.el

the fringe indicator is missing at first. But it appears after switching to another window and back again, and seems to be working correctly from now on.

Note that the order of loading these packages is crucial. This issue does not happen if treemacs-magit is loaded before org-extra-emphasis.

Alexander-Miller commented 4 months ago

Looking into it.

Alexander-Miller commented 4 months ago

I can't reproduce it locally. I did however recently fix a fringe-indicator issue that might be related. Can you check if https://github.com/Alexander-Miller/treemacs/commit/923fbbdea57b27ed3293079b13846206add85d9d helps on your end?

AndreasMatthias commented 4 months ago

It's still the same. No difference.

It's not a big issue, but I wonder why you cannot reproduce this effect. Maybe the depending packages of treemacs or org-extra-emphase make a difference?

AndreasMatthias commented 4 months ago

There's another think that might be related: After starting emacs the hl-line (light green background) is missing in the treemacs buffer. But after the very first keystoke it appears magically. This seems to me like some initialization code is not running in my setup.

I can replicate this with an even easlier startup file:

start.el:

(require 'package)
(package-initialize)
(use-package treemacs)
(treemacs)
emacs -Q -l start.el
Alexander-Miller commented 4 months ago

It's not your setup, hl-line is bound to post-command-hook, and the fringe indicator is bound to hl-line. Without an interactive command there is no initialization.

This one was fun to figure out - the fringe indicator wouldn't show up unless you manually call redisplay :vomiting_face: .

I've created a special starter to deal with this case. Try it out first, if it works for you I'll push it to master:

;;;###autoload
(defun treemacs-start-on-boot (&optional focus-treemacs)
  "Initializer specifically to start treemacs as part of your init file.

Ensures that all visual elements are present, which might otherwise be lacking
because their setup isn't run when treemacs isn't started from an interactive
command.

FOCUS-TREEMACS indicates whether the treemacs window should be focussed."
  (-let [initial-window (selected-window)]
    (treemacs)
    (hl-line-highlight)
    (redisplay)
    (unless focus-treemacs (select-window initial-window))))
AndreasMatthias commented 4 months ago

Yes, it's working smoothly now. Thank you very much.