Bug: Cursor appears outside window when using variable pitch font
See the attached screenshot:
The red line is my cursor, deep into the margin of the window.
Some information that may be useful:
- Using variable width font mode
- Using visual-line-mode
- No other significant visual modes being used
Steps to reproduce:
- Write some text that nears the right margin
- Add 2 spaces, where the first space reaches the edge of the document
- The second space will (sometimes) cause this visual
Happy to work with you to resolve this, with a little guidance.
Hi, thanks for the report.
I've encountered this quite regularly and tried to fix it just as much, without success. It's frustrating.
It's actually displaying in the fringe; the margin is the smaller gap inside, and I'm pretty sure it's intended behaviour of the fringe. You can see this if you open a new buffer, set fringe-mode to nil (default), enable visual-line-mode, and then if you then add a line of characters the full width of the window. You'll see the cursor display in the fringe (easier to see with a block cursor).
I think there's not much I can do about this as the Emacs window display code is a mess that few people understand. If it bothers you, you can set olivetti-style to nil, which will use just margins.
I'll keep this issue open in case there is something that can be done.
Hi,
I have the same problem with lines that fit exactly into the widnow-body-width. For this case, by default, Emacs allows the line to stay unwrapped and places the newline character into the fringe. When the cursor is on the newline character it is displayed in the fringe. If the olivetti style is set to fancy, the cursor is displayed far on the right side, because that is where the fringe is in this case.
I have two solutions so far, each with its own tradeoffs.
- Disable the "newline in the fringe" feature. This way, the cursor will not go into the fringe, but the text that otherwise would have fit into one line will now be wrapped.
(defun my/no-newline-in-fringe ()
(setq-local overflow-newline-into-fringe nil))
(add-hook 'olivetti-mode-hook #'my/no-newline-in-fringe)
- Hide the cursor in the fringe. This way, the cursor can still go into the fringe, but it will be hidden while it is there. I can imagine that this may be confusing at times.
(defun my/hide-fringe-cursor ()
(setq-local fringe-cursor-alist
'((box . empty-fringe-bitmap) (hollow . empty-fringe-bitmap)
(bar . empty-fringe-bitmap) (hbar . empty-fringe-bitmap)
(hollow-small . empty-fringe-bitmap))))
(add-hook 'olivetti-mode-hook #'my/hide-fringe-cursor)