Repository navigation
Char measurement - #6083
Char measurement#6083as-cii wants to merge 67 commits into
Conversation
There was a problem hiding this comment.
I very much like this approach of just keeping a parallel array.
|
I'm wondering if rather than storing the widths of each character at each position if it wouldn't be easier to just store a running total. So if every character were 10px wide on a line with 4 characters, it would be |
|
🚀 Looking forward to collaborating on this problem with you. |
8c8d691 to
a9f3d88
Compare
a9f3d88 to
b0ec19f
Compare
55d5281 to
f87ad85
Compare
This eliminates visual glitches altogether. Code-wise is very messy, but apparently this may be a good way to measure characters 👍
Because we need to add css classes to lines when they're rendered
I was just thinking about this and it's definitely something we could do. I wonder, however, if we could make it even faster 😮 What if, while measuring lines, we stored:
If we manage to do this, then By the way, specs are 💚 now (exception made for those referring to scoped char widths) and it would be great if you could have a second look at this. Thank you 🙇 In the meantime I'll try to put a bit of thought into a reflow-less solution, even though I feel like this PR performs quite well. |
|
@nathansobo: as discussed yesterday, I am still working to make this mergeable and this will hopefully happen by the end of this week 🔥 Right now there are still a few things I need to address. Specifically:
In the meantime, however, it would be great if you could start having a look at this and leave some comments wherever you feel we should change something. Code-wise this is not perfect yet and, since it has been up for a while and I experimented a lot, there may be a bunch of things we want to refine and do better. Thanks! 🙇 |
There was a problem hiding this comment.
I am not super happy with the name of this method. I couldn't come up with something clever and everything always felt like a mouthful. Any ideas how could we improve it? 💭
There was a problem hiding this comment.
Only a slight improvement: setLeftPixelPositionForPoint. I think emphasizing pixels is a good idea.
# Conflicts: # src/lines-component.coffee # src/text-editor-presenter.coffee
|
Will this address #3821? I switched from Sublime originally b/c ligatures worked in Atom... they broke a few versions back and it would be great to have it for fonts like Hasklig and Fire Code. |
|
Yeah, it should fix ligatures. We need to try something more efficient than the current state of this PR because it has a bit too much overhead. |
|
Wanted to provide a status update on this because implementing correct character measurement is becoming a bottleneck for other efforts, such as CJK-aware softwrap. @as-cii feel free to chime in and fill in any details I may be missing. @as-cii and I had a screen sharing session about this PR a few weeks back, and concluded that the measurement overheads for the current state of this PR are probably too high. Our overall goal is to be able to compute the horizontal pixel position of a column at any time without reading from the document (which causes reflows).
Will this new approach work? Not sure. But it's the next thing we'd like to try. Other ideas are welcome, but remember that it can't rely on reading from the document. |
|
@nathansobo: Will this approach allow positioning on lines that have margins or padding, or allow some other means of changing softwrap boundaries throughout the text editor? |
|
@superlou I'm not sure how much CSS applied to lines it's going to be realistic to support. Any supported styling will need to be sampled for measurement in the other document, and covering every possible thing people may want to style positioning wise could end up being pretty complicated. So we can try, but we may need to stick to CSS for styling fonts and colors and add other editor-specific mechanisms for controlling soft wrap behavior etc. We'll see how it goes. |
|
Not sure if it's related to this but I'm having issues with opentype |
|
@larsenwork Nothing has really changed in this area for a while, so I'd say it's unlikely. You can still open another issue however. |
|
Is this still a thing? |
|
@alexandernst Yep. It's still happening. @as-cii has been churning through a zillion alternatives looking for the best approach. It's looking increasingly like just eating a small forced reflow might be the best approach. We're getting there. |
Fixes #6055
This is still a work in progress: code is messy and specs are not passing yet.
With this PR we basically wrap every character with a span so that we're able to measure it. This helps to calculate the real character's width on screen: whenever this is not possible, however, the current solution falls back to@defaultCharWidth.We have split the
TextEditorPresenterand theTextEditorComponentupdates in two phases: pre-measure and post-measure. The former should calculate anything related to lines, whereas the latter performs updates which need to be based on lines measurement.