pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.24k stars 137 forks source link

[pulsar-next] Character width measurement is incorrect on Electron 30 #1102

Open savetheclocktower opened 1 week ago

savetheclocktower commented 1 week ago

Thanks in advance for your bug report!

What happened?

On newer Electron, the text editor soft-wraps too early because TextEditor thinks that an individual character is wider than it actually is.

Screenshot 2024-09-20 at 5 35 16 PM

These four characters are rendered hidden (I've just made them visible for illustration) and are used as examples of the width of a “normal” character, a double-width character, a half-width character, and a Korean character, respectively.

But with identical font settings, PulsarNext thought the character that had these metrics on Pulsar 1.121…

Screenshot 2024-09-20 at 5 38 58 PM

…was a bit wider and taller:

Screenshot 2024-09-20 at 5 38 45 PM

After some experimentation, I found that this is a side-effect of the x sharing a line with other characters — if I delete the other three, the span with the x reverts to the width we expect.

So we can isolate the four characters in different block-level elements to eliminate any possible effects on one another. We should also change the metric that computes the editor line height by having it measure each of those four block elements and picking the tallest one.

I know this will get lost in the weeds unless I write it down here; this is basically a note to my future self.

Pulsar version

some weird version with Electron 30

Which OS does this happen on?

❓ Other(Please specify in the OS details field below)

OS details

N/A

Which CPU architecture are you running this on?

None

What steps are needed to reproduce this?

Additional Information:

No response