Open johannes-mueller opened 3 years ago
I've have this same issue, only workaround I've found is to set highlight-indent-guides-method
to'column
. Any other method causes this issue.
Ok, I've done some digging. And I can confirm it happens when:
highlight-indent-guides-mode
is enabledhighlight-indent-guides-method
is set to 'character
or 'bitmap
whitespace-mode
is enabled0
)The cause of the incorrect cursor movement is the temporary-goal-column
variable being set to the number of characters +1 from the line above the current line, instead of the cursor position in the current line (0). This happens inside of the line-move-visual
function, which uses the posn-at-point
function to get current position of the cursor visually within the current window.
For some reason, when the above listed conditions are true, posn-at-point
returns a X positional value equal to the end of the previous line, rather than the beginning of the current line.
This is sadly where both my time and knowledge runs out at the moment. posn-at-point
is implemented in C, which I don't really know, and it's also outside of my knowledge of Emac's internals.
If it helps anyone, I started debugging this by doing M-x debug-watch RET temporary-goal-column
, and following the rabbit hole downwards.
Since this issue is open since 2020-12-27 - and resolution seems to be illusive, perhaps a good-enough-solution should be to let highlight-indent-guides
have the option to distinguish between tabs and spaces.
I need to find some time to double check, I believe I found the part of the cause of this issue a while back while debugging an issue with copilot.el.
Basically, removing newline-mark
from whitespace-style
should avoid this issue. Obviously not a great fix if you really want to keep newline-mark
though.
I am also experiencing this issue and it does seem to be a conflict between whitespace-mode
and highlight-indent-guides-mode
.
The example given in the introductory post for this issue doesn't seem to get across just how disruptive this issue can be. On large files, inter-line cursor movements can be completely unpredictable: sometimes it stays in the same column, sometimes it's shifted some arbitrary number of spaces, and sometimes it's clear at the end (or beginning) of the line. Obviously, this can be extremely frustrating.
I agree that disabling newline-mark
is not ideal. In fact, a big reason I use whitespace-mode
is for the additional markup, including but not limited to newline-mark
(for example, I also use space-mark
). However, I have tried disabling whitespace-mode
entirely and found it helpful enough, so thanks for that.
I suspect that it's more than just newline-mark
that is affecting cursor movements. And just thinking about it without digging into the source code, I think that the fix would involve highlight-indent-guides-mode
accounting for the extra number of characters that are being inserted by whitespace-mode
. If you've only been running with newline-mark
, try enabling space-mark
or tab-mark
in addition and see if the problem becomes more pronounced.
I am getting a glitch when I use hightlight-indent-guides.el in combination with whitespace.el regarding cursor movement.
Steps to reproduce
.emacs.d/elpa
eval-buffer
it:(add-hook 'prog-mode-hook #'whitespace-mode) (add-hook 'prog-mode-hook #'highlight-indent-guides-mode)
C-SPC
C-n
Expected behavior
The cursor should end up in line 3, column 1
Observed behavior
The cursor ends up in line 3 column 10
System information
emacs-27.1 ubuntu 20.4 amd64 highlight-indent-guides 20200820.2328