Sublime Forum

How to find wrapped line lengths

#1

I have a plugin which creates column selections (similar to Sublime’s alt + click & drag - plugin here).

But it doesn’t work on wrapped lines, because I don’t know where the lines wrap, and I can’t seem to find anything in the documentation that would tell me where they are wrapped.

Is there a way to iterate over the visual lines of the view? Rather than the actual lines?
Or, at least is there a way to divide a line into its wrapped regions?

0 Likes

#2

View.text_to_layout() is the closest thing to what you want, but it’s not going to lend itself to an efficient solution

2 Likes

#3

That’s what I thought, but that gives me pixel coords so I’ll have to do some hacky math to check for lines with unicode/emoji/larger characters and such to get the actual wrapped extent - or just continually check the visual end of the buffer each time… I might just give that a miss for now then. :sweat_smile:

EDIT: I’ve made a feature request here. :slight_smile:

0 Likes