abo-abo / avy

Jump to things in Emacs tree-style
1.73k stars 110 forks source link

Is there a workaround for shifted characters in variable-pitch-mode? #348

Open Dima-369 opened 2 years ago

Dima-369 commented 2 years ago

I really love variable pitch fonts and try to avoid monospaced fonts where possible.

This is a slight issue with using avy because it uses an overlay to replace characters and it results in the characters being shifted a little bit as the characters have differing widths. This is often not an issue but is annoying once words start to break differently to the new line.

Here are some screenshots:

image

Here I invoke avy-goto-word-1 and enter character h. In this scenario, I want to jump to hello but as the words break differently the overlay ends up on the next line.

image

As an comparison, this is how PhpStorm does it with the AceJump Lite extension. The overlay does not replace the character behind, but is in that sense a 'real' overlay and has the benefit that the underlying characters are never shifted. Still, it is not perfect as the overlay hints sometimes do not fully occupy the characters below but I don't find that an issue for me.

image

Is something like this possible in Emacs as well or does anyone know of a workaround, so the characters are not shifted for variable pitch fonts?

Dima-369 commented 2 years ago

I wondered if the overlay could be done with (child) frames, like in https://github.com/elizagamedev/power-mode.el for each overlay character. In that case, the characters below are not replaced.

But not sure of the work required to implement that and how negatively it would impact performance.