Different buffer coordinates for folded code


I’m wanting to know the line in the file/buffer that the user is currently on. If I click on line 5 of a buffer and call

=> Point {row: 4, column: 0}

That makes sense. However if I fold the code at line 5 I get a different result

=> Point {row: 5, column: 0}

If I click on another row, then back to row 5, I get Point: {row: 4, column: 0} as the result again.

Having read through the TextEditor documentation I would have thought that the Buffer position was irrespective to the code being folded or not, so I don’t understand why I get the different return values.


Can you give an example of the code that was folded that reproduces this issue?

var strVal = "a string value";
var arrVal = [1,2,3,4];

var intValue = 100;
var obj = {
  foo: 'bar'

One thing I did notice is that when you fold code, the cursor stops blinking. When you fold code, does the cursor drop to the line below?


You might be positioning the cursor by clicking in the gutter. I don’t have time to look at this right now, but that’s my current theory.