Uncaught TypeError: Cannot read property 'getBufferPosition' of undefined


#1

I get that error when trying to get the position of the cursor. I used editor.Cursor.getBuffferPosition() and that came up. According to the APIs and the Cursor class, that should work. Is there something I’m missing? Or is there a better way to get cursor positioning? To be precise, I’m trying to get the row of the cursor, and I tried that by doing the above command and accessing the value at index 0. But obviously, that doesn’t work. What am I doing wrong?

Thanks in advance!


#2

Should it? You can try atom.workspace.getActiveTextEditor().Cursor in the dev tools console, and it doesn’t work.

Try editor.getCursorBufferPosition().


#3

After getting the buffer position, you should be accessing the row with .row instead of [0].


#4

Thank you! I think I probably just read the docs wrong or something. This is really helpful.