xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
16.98k stars 1.59k forks source link

Rendering issues with webgl and ligatures #3303

Open LabhanshAgrawal opened 3 years ago

LabhanshAgrawal commented 3 years ago

Details

Steps to reproduce

Happened to me using the demo with zsh with powerlevel10k Comparing canvas vs webgl with ligatures

Canvas

Screenshot 2021-04-08 at 20 17 55

Webgl

Screenshot 2021-04-08 at 20 19 35

Below, I'm using suggestions and syntax highlighting plugins for zsh It's suggesting === (untyped part of the suggestion should be in gray)

On typing = Both

Screenshot 2021-04-08 at 20 18 09

On typing == Canvas

Screenshot 2021-04-08 at 20 19 09

Webgl

Screenshot 2021-04-08 at 20 20 21

On typing === Canvas

Screenshot 2021-04-08 at 20 19 18

Webgl

Screenshot 2021-04-08 at 20 20 28

Looks like remnants of earlier paint are there in webgl

Tyriar commented 3 years ago

The grey = is tracked in https://github.com/xtermjs/xterm.js/issues/3288, not sure what's happening with the :, what font is this?

LabhanshAgrawal commented 3 years ago

Fira Code It's the demo running without any changes (just turned on ligatures & webgl and opened zsh)

LabhanshAgrawal commented 3 years ago

It looks like the character from inside the cursor is staying on.

Tyriar commented 3 years ago

It looks like the character from inside the cursor is staying on.

I think that's actually ideal imo, but I don't use ligatures so not 100% sure. The dom renderer is a little bad atm since the cursor highlights all chars in the ligature.

LabhanshAgrawal commented 3 years ago

what I meant was that the artifact for character inside the cursor is left even after typing and the cursor moving 1 place ahead If you look at the sequence from 1->3 ='s the grey = that stays on is the one from inside the cursor

For the dom I guess it's happening since the joined characters are in the same span and the cursor is covering it full. Might be hard to fix as it'd need to be a separate element then. And might cause issues with emoji's or cjk as they are multi character too.

jerch commented 3 years ago

For the dom I guess it's happening since the joined characters are in the same span and the cursor is covering it full. Might be hard to fix as it'd need to be a separate element then. And might cause issues with emoji's or cjk as they are multi character too.

Yep, compound unicode chars (grapheme clusters) basically have the same issue, imho this was the reason for inventing IMEs in the first place - the user needs a way to interact with its "construction phase" (cursor access to its atomic entities).

AFAIK word processors treat clusters this way - once they are constructed the normal cursor would not allow to jump into the atomics anymore (treated as a single char, cursor jumps right over it, BS would delete it as a whole), but have the ability to re-enter the construction phase by some additional action to modify the atomics again.

While we can learn from word processors, how a proper cursor based interaction with clusters may look like, it is not quite easy to apply for a grid-aligned terminal. We basically would need a way to re-enter the IME construction once again, no clue if thats possible somehow.

Ligatures as used from coding fonts are somewhat special here as they output different glyphs for consecutive chars, that still show normal monospaced cursor progression. Imho here we should break the ligature, maybe simply skip the joiner if the cursor is above?

LabhanshAgrawal commented 2 years ago

Looks like the rendering issues go further See https://github.com/vercel/hyper/issues/5757

npezza93 commented 7 months ago

fwiw @Tyriar @LabhanshAgrawal if you manually clear the texture atlas this goes away. perhaps theres some key that's missing in cache key?

jerch commented 7 months ago

@npezza93 Does this still happen with v5.3? Because in older versions there was a bug in the cache altas, which got fixed around 5.3 (see #4534).

npezza93 commented 7 months ago

@jerch yep!