seagle0128 / doom-modeline

A fancy and fast mode-line inspired by minimalism design.
https://seagle0128.github.io/doom-modeline/
GNU General Public License v3.0
1.31k stars 158 forks source link

[Bug] Huge cap between mode name & icon and the of the indicators #745

Open Thaodan opened 1 week ago

Thaodan commented 1 week ago

Thank you for the bug report

Bug description

With the recent changes I noticed a huge gap between the current mode name indicator and the rest of the notification icons such as IRC, LSP etc.

Steps to reproduce

No action necessary just start emacs with doom-modeline enabled and compare with not enabled.

Expected behavior

no gap.

OS

Linux

Emacs Version

31

Emacs Configurations

https://github.com/thaodan/emacs.d

Error callstack

No response

Anything else

No doom-modenline: Screenshot_20241114_222318

Doom modeline while visiting and org-mode buffer: Screenshot_20241114_221949

Doom-modeline while visting a c++-mode buffer: Screenshot_20241114_222127

Same thing but fullscreen: Screenshot_20241114_222233

seagle0128 commented 1 week ago

There's no related changes recently, and I couldn't reproduce. Do you happen to know which changes impact? I guess it might be related to the recent changes of Emacs 31. Can you please test with 29 or 30?

Thaodan commented 1 week ago

I can try. Could it help to evaluate parts of the modeline format functions?

This is the content of eval of the doom-modeline eval function:

(((:eval (doom-modeline-segment--eldoc))
  (:eval (doom-modeline-segment--bar))
  (:eval (doom-modeline-segment--workspace-name))
  (:eval (doom-modeline-segment--window-number))
  (:eval (doom-modeline-segment--modals))
  (:eval (doom-modeline-segment--matches))
  (:eval (doom-modeline-segment--follow))
  (:eval (doom-modeline-segment--buffer-info))
  (:eval (doom-modeline-segment--remote-host))
  (:eval (doom-modeline-segment--buffer-position)) ...)
 #(" " 0 1
   (face (:inherit (doom-modeline mode-line-active)) display
         (space :align-to (-392))))
 ((:eval (doom-modeline-segment--compilation))
  (:eval (doom-modeline-segment--objed-state))
  (:eval (doom-modeline-segment--misc-info))
  (:eval (doom-modeline-segment--persp-name))
  (:eval (doom-modeline-segment--battery))
  (:eval (doom-modeline-segment--grip))
  (:eval (doom-modeline-segment--irc))
  (:eval (doom-modeline-segment--mu4e))
  (:eval (doom-modeline-segment--gnus))
  (:eval (doom-modeline-segment--github)) ...))

I think the issue could be caused by any of the Emacs functions used in (doom-modeline-def-modeline).

seagle0128 commented 1 week ago

I think the issue could be caused by any of the Emacs functions used in (doom-modeline-def-modeline).

Maybe you can check if string-pixel-width was changed.

Thaodan commented 1 week ago

Vincent Zhang @.***> writes:

I think the issue could be caused by any of the Emacs functions used in (doom-modeline-def-modeline).

Maybe you can check if string-pixel-width was changed.

That could be the case. I have the issue on a high dpi 4k system while on my notebook I have a 2k display where the issue doesn't exist.

Will check and report back.

Thaodan commented 1 week ago

Vincent Zhang @.***> writes:

I think the issue could be caused by any of the Emacs functions used in (doom-modeline-def-modeline).

Maybe you can check if string-pixel-width was changed.

I think I have tracked down the origin of the issue I face. The issue first of all doesn't always happen but only in certain variants with enough segments.

To debug the issue better I added the calculation of align-value further up in doom-modeline-def-modeline.

The error must be somewhere in the calculation of the fourth value as shown in the backtrace.

Here's the backtrace I have so far: Debugger entered--returning value: -440 -(1892 0 0 12 0 2320) (let ((sym (intern (format "doom-modeline-format--%s" name))) (lhs-forms (doom-modeline--prepare-segments lhs)) (rhs-forms (doom-modeline--prepare-segments rhs)) (rhs-str (format-mode-line (cons "" rhs-forms))) (rhs-width (progn (add-face-text-property 0 (length rhs-str) 'mode-line t rhs-str) (doom-modeline-string-pixel-width rhs-str))) (align-value (- (window-pixel-width) (window-scroll-bar-width) (window-right-divider-width) ( (or (cdr (window-margins)) 1) (frame-char-width)) (cond ((eq mode-line-right-align-edge 'right-margin) (let nil (or (cdr (window-margins)) 0))) ((eq mode-line-right-align-edge 'right-fringe) (let nil (or (car (cdr (window-fringes))) 0))) (t (let nil 0))) rhs-width))

Thaodan commented 6 days ago

The issue must be somewhere in string with. Even when I don't use the string-pixel-width function the value resturned by string-width is off too.

The issue doesn't happen immediately after I start Emacs but once after I activate my transient launcher for example the bug is triggered.

Thaodan commented 6 days ago

I just triggered the issue when opening circe. So I guess the issue could be related to the irc indicator.

seagle0128 commented 6 days ago

I noticed string-pixel-width was changed in 31 recently.

https://github.com/emacs-mirror/emacs/blob/eee0ed8442aa78320a3e578ab290df145fb49624/lisp/emacs-lisp/subr-x.el#L390-L422

Thaodan commented 2 days ago

For me only the IRC segment could trigger the bug from my current testing.

Could it be that the length of the modeline doesn't update when a segment changes?

I tested a few of those changes to see if they cause the bugs. Which one looks like it should cause the issue?