diff --git a/www/common/text-cursor.js b/www/common/text-cursor.js index eaf33d0b3..cd8f52213 100644 --- a/www/common/text-cursor.js +++ b/www/common/text-cursor.js @@ -3,6 +3,7 @@ define([ var module = { exports: {} }; var transformCursor = function (cursor, op) { if (!op) { return cursor; } + var pos = op.offset; var remove = op.toRemove; var insert = op.toInsert.length; @@ -17,10 +18,12 @@ define([ }; module.exports.transformCursor = function (cursor, ops) { if (Array.isArray(ops)) { - for (var i = ops.length - 1; i >= 0; i--) { transformCursor(cursor, ops[i]); } - return; + for (var i = ops.length - 1; i >= 0; i--) { + cursor = transformCursor(cursor, ops[i]); + } + return cursor; } - transformCursor(ops); + return transformCursor(ops); }; return module.exports; -}); \ No newline at end of file +});