Handling proportional fonts in editor

I've been thinking about how best to support proportional fonts in the editor lately, and trying to read up on any history here.

Problem

It seems like the main issue is that most of the styles regarding this involve adding text-indent with a value based on ch. For context, ch represents the width of a 0 character in the font. This works fine for monospaced fonts, since all the characters have the same width, but breaks down when your font is proportional, since the characters vary in size!

One way this has manifested a few times is in the awkward layout of multi-line list items

Other solutions

There's a mention of this working properly in Obsidian:

I believe that Obsidian is doing a text-measuring approach, where they do layout, then measure the size of the text span and adjust the offset in the next render. (I'm guessing this based on a forum thread complaining about it jumping in some cases
Editor text-indent and padding-inline-start calculating improperly - Bug reports - Obsidian Forum)

Another option would be to make the indentation based on em which isn't relative to the actual font metrics (but rather the font size). This would make the behavior roughly consistent between mono and proportional, but I think it might lead to jumping.

Idea

The option I've been considering most strongly, I haven't seen anywhere else yet, but seems interesting --

Basically, if we add a codemirror decoration/mark plugin that annotates these prefix ranges, we could make it possible to force them to remain monospaced while the rest of the editor text is proportional. This feels kind of nice because this text isn't really being used as text in these scenarios anyway. It means that ch will still work, and we could have proportional text with zero jumping, without needing to do measurement.

I put up a (possibly half-baked, certainly under-explained) PR related to this, but wanted to see if there was more general interest in this kind of solution before pushing it further.

I feel like ideally, proportional editor font support would look like -- the default CSS defines a --proportional-editor-font, defaulting to var(--editor-font). Then all the "regular" text can use --proportional-editor-font and the .sb-layout-prefix and any code blocks can use --editor-font. (Alternatively, a --monospace-editor-font that defaults to --editor-font).

That way people can easily change the font to proportional without breaking their layout/code, like in changing to proportional font also makes text within backticks proportional · Issue #1494 · silverbulletmd/silverbullet · GitHub

Any thoughts? Past discussions I missed?
Nothing terribly urgent obviously, and I'm sure there's tons of work in more important areas, but just wanted to share my thoughts

I took a stab at this problem a couple of times, it's hell on earth. Both because the current silverbullet css and html is a mess, but also because this is generally an annoying problem. I'd love to see it fixed, but be warned.

This sounds like a great idea.

I wonder if it would also be a solutionfor this old problem: How to make second line in task items aligned? - #2 by Mr.Red