diff --git a/core/modules/editor/operations/text/prefix-lines.js b/core/modules/editor/operations/text/prefix-lines.js index 6d065298b..d511b4b06 100644 --- a/core/modules/editor/operations/text/prefix-lines.js +++ b/core/modules/editor/operations/text/prefix-lines.js @@ -21,7 +21,7 @@ exports["prefix-lines"] = function(event,operation) { var lines = operation.text.substring(operation.cutStart,operation.cutEnd).split(/\r?\n/mg); $tw.utils.each(lines,function(line,index) { // Compose the required prefix - var prefix = event.paramObject.character.repeat(event.paramObject.count); + var prefix = $tw.utils.repeat(event.paramObject.character,event.paramObject.count); // Check if we already have the required prefix if(line.substring(0,prefix.length) === prefix) { // If so, remove the prefix diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index 2bea63728..054cfa495 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -17,7 +17,18 @@ Display a warning, in colour if we're on a terminal */ exports.warning = function(text) { console.log($tw.node ? "\x1b[1;33m" + text + "\x1b[0m" : text); -} +}; + +/* +Repeats a string +*/ +exports.repeat = function(str,count) { + var result = ""; + for(var t=0;t