This isn't copying cursor into newCursor (after this line of code, newCursor.ch === cursor.ch) and I'd be worried about some bit of code being added later on below that uses cursor after it has been modified.

You could eliminate newCursor and make it obvious that you are modifying cursor here, or you could make newCursor a true copy of cursor (`newCursor = {line: cursor.line, ch: cursor.ch};`)