Question

I'm trying to play back user input in ACE editor. Having collected a queue of deltas, I'm trying to loop over the queue and show the changes with delays.

Here's some slightly simplified code:

// 'queue' is queue of delta objects
var i = 0;
function playbackLoop() {
// setTimeout( function() {
      editor.getSession().getDocument().applyDeltas([queue[i]]);
      i++;
      if(i < queue.length)
           playbackLoop();
// }, 250);
}

This code works -- as in, it leaves me with a perfect copy of what the user typed in.

When I uncomment the lines for setTimeout, upon playback the cursor in the editor moves every 250ms, but no characters appear. So I'm left with the conclusion that setTimeout is interfering with applyDeltas.

I'm guessing applyDeltas relies on some hidden internals, but I have no idea what they can be.

Thanks!

Was it helpful?

Solution

Maybe there is a problem with deltas in the queue? It works fine here http://jsbin.com/ojijeb/320/edit. just edit and press replay

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top