syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.69k stars 4.9k forks source link

Wrong size of line number at cursor #10877

Closed gl4eqen closed 6 years ago

gl4eqen commented 6 years ago

Description :octocat:

Wrong size of line number at cursor

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: After C-x C-+, on line with cursor present line numbers size remains default instead of bigger/smaller one.

screenshot

Expected behaviour: :heart: :smile: Every line number has got the same size according to current zoom.

System Info :computer:

Default config on develop for purpose

gl4eqen commented 6 years ago

No one has reproduced the issue since June? It is pretty apparent bug.

OndrejZapletal commented 6 years ago

I don't know if it helps anyone but I was able to reproduce this issue as well. But for me it seems to be happening only with spacemacs-dark or spacemacs-light themes.

System Info :computer:

d12frosted commented 6 years ago

No one has reproduced the issue since June? It is pretty apparent bug

I think more people have experienced this issue. It just, no one has taken an effort to hunt this bug down and fix it.


@OndrejZapletal this is interesting.

@nashamri you might be interested in this 😸

gl4eqen commented 6 years ago

I'm an illiterate when it comes to lisp BUT my incredible general-purpose-programming-skills led me to commenting out lines in .emacs.d/core/libs/spacemacs-theme/spacemacs-common.el:584-587 and it appears to restore proper number lines behaviour.

image

However, I suppose it was purposely written to fix some bug so such change might break something.

bmag commented 6 years ago

I was able to reproduce the bug, and adding a :inherit line-number property to the line-number-current-line face in spacemacs-common.el also solves the issue. There seems to be some problem with line-number-current-line not inheriting properties from any face in spacemacs-theme. The command for scaling the text (text-scale-adjust) works by changing the default face (see text-scale-mode), so line-number-current-line not inheriting from the default face (directly or indirectly) would explain the problem.

bmag commented 6 years ago

@nashamri I looked a bit into this and found several problems. First, the whole when clause doesn't do what it needs to do:

(when (>= emacs-major-version 26)
  `(line-number ((,class (:foreground ,lnum :background ,bg2))))
  `(line-number-current-line ((,class (:foreground ,base :background ,bg2)))))

The when returns just the last sexp, so the call to custom-theme-set-faces only includes line-number-current-line. The line-number face is not changed.

For Emacs 25, the when returns nil. I don't know how custom-theme-set-faces handles a nil entry, but I assume if it was a problem we would've gotten a ton of issue reports already.

AFAICT, the line-number face is supposed to inherit from default, and line-number-current-line is supposed to inherit from line-number.

Replacing the single when clause with two separate seems to work for me:

(when (>= emacs-major-version 26)
  `(line-number ((,class (:foreground ,lnum :background ,bg2 :inherit default)))))
(when (>= emacs-major-version 26)
  `(line-number-current-line ((,class (:foreground ,base :background ,bg2 :inherit line-number)))))

It isn't pretty, but solving the problem in a more elegant way would require bigger changes to dyn-let or create-spacemacs-theme and might not be worth the trouble.

What if we remove the condition entirely and set line-number and line-number-current-line also for Emacs 25? Calling custom-theme-set-faces in stock Emacs 25.3 (without spacemacs-theme) to set line-number doesn't cause any problems from what I could test.

gl4eqen commented 6 years ago

@bmag Your solution works for me as well. Can we make it a PR to develop?

bmag commented 6 years ago

@Glaeqen I will make a PR upstream to spacemacs-theme.

bmag commented 6 years ago

Made the PR.

bmag commented 6 years ago

Fixed in develop by https://github.com/syl20bnr/spacemacs/pull/11570 :smile: This bug doesn't affect master branch, so closing it.

JoshTRN commented 2 years ago

Glad I found this. I use a custom theme and I didn't realize it was theme relative and it wasn't inheriting the normal line number font size.