Reputation: 3868
I want to do something like a background worker. It should automatically update some code (at a different place than the cursor is) without moving the cursor to the last changed word. Is this possible with editor.session.replace or .insert?
Upvotes: 1
Views: 1307
Reputation: 2208
One way of doing this is, Store the present cursor position, Insert the data and set the cursor position to the initial point.
//Get the Current Positon
var currentPosition = editor.selection.getCursor();
//Insert data into the editor
editor.setValue(data);
editor.clearSelection();
//Set the cursor to the Initial Point
editor.gotoLine(currentPosition.row, currentPosition.column);
Upvotes: 1