Closed DivineDominion closed 5 months ago
Ah, since sideline--align
is a function, it'd be possible to tweak the offset there, too, and use a length offset of 2
instead of 1
:
(defun sideline--align (&rest lengths)
"Align sideline string by LENGTHS from the right of the window."
(list (* (window-font-width)
(+ (apply #'+ lengths) (if (display-graphic-p) 2 3)))))
That's easier to override in my config. Ideas how to figure out the root problem still welcome, though :)
Can you try with emacs -q
? Generally, sideline
can be miscalculated depending on the packages you use. Can you try turning some minor modes on/off? Let me know if you find anything. I would like to include a fix in this package. :)
I have the same problem.
Would this be a macOS-specific problem? 🤔 Sorry, I'm still a bit confuse.
I am running pgtk emacs on linux and I use Source Code Pro font. If I use another font (DejaVu Sans for instance) the problem disappear.
I think the issue is due to the font calculation? 🤔
I would need sometime to investigate it.
I've tried use the Source Code Pro on Windows, but it seems to work. 😕
Here is how it looks:
I don't think the problem comes from sideline--str-len
, here is what I get:
(length "antoineB, oct. 28 2023 15:49:54 â—‰ Add sql-ts-mode.el file to base the mode on another") ;; 85
(sideline--str-len "antoineB, oct. 28 2023 15:49:54 â—‰ Add sql-ts-mode.el file to base the mode on another") ;; 85
Here is without the fringes.
I have resized to different size but it doesn't change the problem.
And I forgot to mention I have the same problem with awesome-tray package.
Can you try the latest on the master branch? I've done a couple of improvements.
I hope these changes solve this issue since I don't know what is causing this bug. 🤔
In this picture we can see that the cursor at the end of the line is halfed,
(- (window-width) (window-max-chars-per-line))
gives 1.
Therefor the sideline-blame shown above is offseted by 1 in sideline--align
.
Another thing I don't understand the sideline-blame message is not characters aligned with the line below even the 2 lines use the same face.
After resizing the window I can align the characters, the sideline-blame text is displayed next to the right border, but the window-width and window-max-chars-per-line values still off by 1 char.
Another thing I don't understand the sideline-blame message is not characters aligned with the line below even the 2 lines use the same face.
My guess is because it's displays from the right? 🤔
After resizing the window I can align the characters, the sideline-blame text is displayed next to the right border, but the window-width and window-max-chars-per-line values still off by 1 char.
Hmmm... I guess there are some miscalculations in the window width.
(defun sideline--align (str offset)
"Align sideline STR from the right of the window.
Argument OFFSET is additional calculation from the left/right alignment."
(list (+
;; If the sideline text is displayed without at least 1 pixel gap from the right fringe and
;; overflow-newline-into-fringe is not true, emacs will line wrap it.
(if (and (display-graphic-p)
(> (nth 1 (window-fringes)) 0)
(not overflow-newline-into-fringe))
1
0)
(* (window-font-width)
(+ offset (if (display-graphic-p)
;; If right fringe is deactivated add 1 offset for line wrap char.
(if (= 0 (nth 1 (window-fringes))) 1 0)
1)))
(sideline--string-pixel-width str))))
The problem was is a char is close with 0 pixel gap to the right fringe and overflow-newline-into-fringe set to nil then emacs line wrap. For @DivineDominion I see you have no right fringe, if you use emacs in a terminal did you try use sideline.el from master ? If you use gui emacs without a fringe you try my function.
Okay, I can finally reproduce this issue with (setq overflow-newline-into-fringe nil)
. 😅
I've tested it, and your solution seems to solve this issue. Can you open a PR for this?
Nice work :)
I found that I needed to remove the
(1- ...)
when right-aligning the sideline overlay.The code is this: https://github.com/emacs-sideline/sideline/blob/20e04fa2fd4dcc0cba47d0336aab37f3f42909d3/sideline.el#L438
The "fix" would be:
I don't quite understand why that's the case, though.
(Am using GUI Emacs for macOS)
I'm not good at debugging Elisp -- I can fiddle with stuff, run it again, and see if it helps, like I did here, but I'm not sure how to figure out the actual culprit. Hints welcome!
Observations
With
(1- ...)
but without truncating lines (my default)With
(1- ...)
and truncating linesThat's bearable, but I found that replacing
(1- len-title)
with justlen-title
fixes things:Without
(1- ...)