Skip to main content

position_query

Function position_query 

Source
pub fn position_query(on_answer: impl FnOnce(PositionAnswer) + 'static) -> u32
Expand description

Numbers one question about where a position of an editor is on screen, and keeps on_answer until the answer arrives.

The number goes into the command that asks it, Batch::query_position_rect, written by whatever holds the editor’s node. The Renderer answers every query exactly once, with the rectangle a caret at that position would be drawn in, or with None where the position is not on screen: scrolled away, folded, outside the document, or in an editor that is gone. on_answer then runs on the UI thread, inside the call that carried the answer, and anything it changes is in the batch that call returns.

It is how a hover card, a rename box or a parameter hint is put next to a word that is not where the caret is.