Hi Thank you for this library!
I can use
state.doc.lineAt(cursor) to figure out the line number, but this seems to be the actual row number in the document (which makes sense!).
Is there a way I could determine the visual line number after wrapping though? I’d like to use it to position a tooltip vertically around a range of text that might wrap. More precisely, I’d like to set
pos for a
Tooltip so that I can guarantee that it won’t overlap with a specific range in the document after wrapping (which I’d be happy to calculate myself if it’s possible).
No. Use direct screen coordinates for that kind of thing.
Thank you! I’m trying to generate the tooltips in the
update function of a
StateField based on the current selection. Is it reasonable to read screen coordinates from the view there?
In general it seems like it would be useful for tooltips to automatically ensure that they don’t overlap with any text positioned inside of a
end, but it doesn’t seem like that’s the case.
No. But you can’t know about line wrapping there in general, since that happens on the view level.
Thanks! Yeah I just ran into that and get “Reading the editor layout isn’t allowed during an update”. I’ll figure something else out - thanks for your help.
For what it’s worth, the tooltip effect I’m trying to create is similar to how it works in Excel:
Excel keeps all tooltips below the entire editor, even if cursor is on the first argument. I’d like to do something similar but have tooltips show below the last argument of the function call that’s currently selected (instead of below the editor).