pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

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

Open savetheclocktower opened this issue 1 year ago • 2 comments

Thanks in advance for your bug report!

  • [X] Have you reproduced issue in safe mode?
  • [X] Have you used the debugging guide to try to resolve the issue?
  • [X] Have you checked our FAQs to make sure your question isn't answered there?
  • [X] Have you checked to make sure your issue does not already exist?
  • [X] Have you checked you are on the latest release of Pulsar?

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?

  • Enable soft wrap
  • Don't worry, you'll see it

Additional Information:

No response

savetheclocktower avatar Sep 21 '24 00:09 savetheclocktower

Oh, that's why my soft wrap is broken!

mauricioszabo avatar Nov 22 '24 15:11 mauricioszabo

I did fix this on updated-latest-electron, so I don't know why I didn't close this bug. I'll make absolutely sure first.

savetheclocktower avatar Nov 25 '24 05:11 savetheclocktower