prettier-emacs icon indicating copy to clipboard operation
prettier-emacs copied to clipboard

Highlighting "flickering" while applying formatting

Open jonkri opened this issue 4 years ago • 2 comments

Under some circumstances, lines lose their syntax highlighting for a while when formatting is applied.

The attached image illustrates it.

demo

I would like for the text not to temporarily turn to the foreground color.

jonkri avatar May 24 '20 18:05 jonkri

prettier mode needs to request re-highlighting after changing the buffer. If you execute: M-x web-mode when highlights are broken, it will fix the highlights. To do this automatically after prettier does its thing:

(eval-after-load 'web-mode
    '(progn
       (add-hook 'web-mode-hook #'add-node-modules-path)
       (add-hook 'after-save-hook #'web-mode)
       (add-hook 'web-mode-hook #'prettier-js-mode)))

keithgabryelski avatar Jun 23 '20 20:06 keithgabryelski

@keithgabryelski:

Thanks for your suggestion, but my problem isn't that the highlight becames broken in a way that the code snippet above fixes. My problem is the "flickering". For a fraction of a second, all the text turns to the foreground color (after which the syntax highlighting is restored automatically, with or without the code snippet that you posted). I would like to avoid this "flickering", if possible, so that the code is always rendered using the correct syntax highlighting, during all milliseconds. :slightly_smiling_face:

I hope that clarifies my problem!

jonkri avatar Jul 02 '20 19:07 jonkri