I have done this to get a characterIndex of a mouse event:
pixelPt = pixelPositionFromMouseEvent(@editor, e) screenPt = @editor.screenPositionForPixelPosition(pixelPt) bufferPt = @editor.bufferPositionForScreenPosition(screenPt) textBuffer = @editor.getBuffer() offset = textBuffer.characterIndexForPosition(bufferPt)
I think this used to work but currently this is broken if I have scrolled down. It works correctly if I’m at the top of the file, but If I scroll down, it doesn’t seem to take into account the scrolling and leaves me with coordinates as if I was at the top.
What am I doing wrong?