Add TextEditorComponent.screenPositionForPixelPositionSync

This method can be used to translate a pixel position to a screen
position even if the line is not currently rendered on screen.
This commit is contained in:
Nathan Sobo
2017-04-20 15:14:35 -06:00
committed by Antonio Scandurra
parent 3d6921cca3
commit 1cc68e408e
3 changed files with 57 additions and 0 deletions

View File

@@ -152,6 +152,22 @@ class TextEditorComponent {
return {top, left}
}
screenPositionForPixelPositionSync (pixelPosition) {
const {model} = this.props
const row = Math.max(0, Math.min(
this.rowForPixelPosition(pixelPosition.top),
model.getApproximateScreenLineCount() - 1
))
if (!this.renderedScreenLineForRow(row)) {
this.requestExtraLineToMeasure(row, model.screenLineForScreenRow(row))
this.updateSyncBeforeMeasuringContent()
this.measureContentDuringUpdateSync()
}
return this.screenPositionForPixelPosition(pixelPosition)
}
scheduleUpdate (nextUpdateOnlyBlinksCursors = false) {
if (!this.visible) return