highlight-indent-guides icon indicating copy to clipboard operation
highlight-indent-guides copied to clipboard

Ghost guide characters when changing indent size

Open okomestudio opened this issue 5 years ago • 12 comments
trafficstars

Say I have this code nicely highlighted with gray guides:

00

When I edit a line (one with <div class="page"> in this case), somehow the character guides get messed up and leave all those "ghost" guide characters (in black) that should not be there:

01

These ghost characters are not real in a sense that they aren't actually edited into the code itself (killing the buffer and reopening the file renders properly with the new indent size).

This happens when I use highlight-indent-guides with the web-mode hook, but it doesn't happen with my Python code (python-mode). Is this some compatibility issue mentioned in README or actually a bug?

okomestudio avatar Dec 28 '19 06:12 okomestudio

Sorry for the late reply, I could have sworn I had already responded to this. Yeah, I can reproduce it, and it only seems to happen in web-mode. There must be some compatibility issue, though not one I was previously aware of. I'll take a closer look at web-mode to see if I can tell what the problem might be.

DarthFennec avatar Mar 23 '20 19:03 DarthFennec

this also happens to me in many lisp modes. Also when some indentation is corrected automatically, e.g. by parinfer or by indent-region

andreyorst avatar Aug 21 '20 18:08 andreyorst

Any progress on this issue? It's quite annoying when this happens. And this indeed happens in many different major-modes.

jcs090218 avatar Oct 12 '20 04:10 jcs090218

This is probably the single most annoying issue that I've personally encountered using this package.

Cons-Cat avatar Dec 14 '20 06:12 Cons-Cat

It might be easier if I had more examples to cross-reference. I've only seen this in web-mode so far, what other modes does it happen in? I still haven't had time for a deep dive into web-mode, but if there's some clear connection between the modes this affects it might shed some light. Beyond that, I'm still planning on a detailed look at web-mode when I get time for it.

DarthFennec avatar Dec 14 '20 23:12 DarthFennec

There are few cases I could reproduce this issue.

Case 1

This occurs when guides is trying to highlight the guides under dotimes operator (image on left). But once the indentation is mess up by deleting the spaces infront of if operator, then the guides seem to be confused? (image on right)

before after
align_before align_after

Case 2

If I try to delete the newline from beginning of line. There are guides left behind the previous line.

before after
del_b del_a

P.S. This is in emacs-lisp-mode

jcs090218 avatar Dec 15 '20 04:12 jcs090218

@jcs090218 Hmm ... yeah neither of these things happen for me, can't reproduce. I'm definitely in emacs-lisp-mode. Perhaps you have a minor mode loaded that's interfering with the update mechanism, or something like that? It seems like font-lock isn't running properly for some reason.

DarthFennec avatar Dec 16 '20 21:12 DarthFennec

also can't reproduce with this particular example, however this happens to me very often with Parinfer-rust-mode when the whole block of indentation is changed.

andreyorst avatar Dec 17 '20 05:12 andreyorst

here's a minimal repro that works for me with emacs -q: highlight-indent-guides-#70.zip

$ cd highlight-indent-guides-#70
$ emacs -q -l repro-init.el bug.el

image By deleting indentation with backspace one by one I get this result:

image

Here's a GIF:

simplescreenrecorder-2020-12-17_10 27 32

This is Emacs version: 27.1, and freshly installed highlight-indent-guides without anything else.

andreyorst avatar Dec 17 '20 07:12 andreyorst

I have this issue as well.

I see it most when I apply auto-formatting via lsp in haskell files.

plcplc avatar Jul 19 '22 13:07 plcplc

In my case this bug is fixed in a particular buffer when I toggle the highlight-indent-guides-mode off and back on again. The issues no longer appears in this buffer.

highlight-indent-guides is loaded as follows:

(use-package highlight-indent-guides
  :ensure t
  :after modus-themes
  :custom
  (highlight-indent-guides-method 'character)
  (highlight-indent-guides-auto-character-face-perc 25)
  :hook
  ((prog-mode text-mode conf-mode) . highlight-indent-guides-mode))

lapinskim avatar Dec 08 '22 13:12 lapinskim

Here is my workaround based on @lapinskim's comment:

(use-package
 highlight-indent-guides
 :init
 (add-hook
  'prog-mode-hook
  (lambda ()
    ;; NOTE: Workaround to fix wired appearance after
    ;; reformatting. See
    ;; https://github.com/DarthFennec/highlight-indent-guides/issues/70#issuecomment-1342713343
    ;; for more information.
    (highlight-indent-guides-mode +1)
    (highlight-indent-guides-mode -1)
    (highlight-indent-guides-mode +1))))

NOTE: Only tested on Emacs 30.0.50

weitanism avatar Mar 09 '23 08:03 weitanism