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.28k stars 158 forks source link

[Bug] doom-modeline causes oversized which-key window #553

Closed PerceptuallyUniform closed 2 years ago

PerceptuallyUniform commented 2 years ago

Thank you for the bug report

Bug description

When using both which-key and doom-modeline, the which-key window opens too large (half the height of the active window) for a split second, before shrinking back to its expected size.

While distracting on its own, it is made worse if the point is on the bottom half of the window, that gets covered by the which-key window, causing the active window to scroll to keep the point visible. In my experiments, setting doom-modeline-height to < 19 resolved the issue.

I don't know if the root cause lies in doom-modeline or which-key.

Steps to reproduce

Open a text file with enough lines in emacs. With point near the top of the window, press C-x to make the which-key window appear. Move the point to 1-2 lines above the top of the which-key window, close the which-key window, then re-open it with C-x. That should cause it to momentarily cover the point and scroll the active window.

Configuration used in testing:

; early-init.el
(setq package-enable-at-startup nil)
; init.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

(use-package which-key
  :config (which-key-mode))

(use-package doom-modeline
  :init (doom-modeline-mode 1)
  ; :config (setq doom-modeline-height 1)  ; Uncomment to fix the bug.
)

Expected behavior

No different than without doom-modeline - the which-key window opens at its final size immediately, and does not cover half the active window before shrinking.

OS

Linux

Emacs Version

27

Emacs Configurations

Vanilla emacs

Error callstack

No response

Anything else

No response

seagle0128 commented 2 years ago

I couldn't reproduce this issue.

  1. Can you please provide recordings or screenshots?
  2. Try (advice-remove #'fit-window-to-buffer :before #'doom-modeline-redisplay), please.
PerceptuallyUniform commented 2 years ago

Recording of this issue attached.

Appending (advice-remove #'fit-window-to-buffer :before #'doom-modeline-redisplay) to init.el produces a Wrong number of arguments: (2 . 2), 3 error during loading, and the issue persists.

which-key_problem.webm

seagle0128 commented 2 years ago

Sorry, try (advice-remove #'fit-window-to-buffer #'doom-modeline-redisplay).

It's not a bug, while a workaround. See

https://github.com/seagle0128/doom-modeline/blob/master/doom-modeline-core.el#L804

PerceptuallyUniform commented 2 years ago

The workaround works, and resolves the issue, thank you.

seagle0128 commented 2 years ago

The workaround works, and resolves the issue, thank you.

Reminder, removing the workaround will cause other issues as the inline comments.