diff --git a/lib/ace/lib/lang.js b/lib/ace/lib/lang.js index 563c7f24..4e6ebf2c 100644 --- a/lib/ace/lib/lang.js +++ b/lib/ace/lib/lang.js @@ -37,13 +37,12 @@ exports.stringReverse = function(string) { exports.stringRepeat = function (string, count) { var result = ''; - while (count) - { + while (count > 0) { if (count & 1) - result += string; + result += string; if (count >>= 1) - string += string; + string += string; } return result; }; diff --git a/lib/ace/multi_select.js b/lib/ace/multi_select.js index e1ecd80c..2940b8e0 100644 --- a/lib/ace/multi_select.js +++ b/lib/ace/multi_select.js @@ -780,23 +780,23 @@ var Editor = require("./editor").Editor; return m; }).map(isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign); - function strRepeat(n, ch) { - return Array(n + 1).join(ch) + function spaces(n) { + return lang.stringRepeat(" ", n); } function alignLeft(m) { - return !m[2] ? m[0] : strRepeat(startW, " ") + m[2] - + strRepeat(textW - m[2].length + endW, " ") + return !m[2] ? m[0] : spaces(startW) + m[2] + + spaces(textW - m[2].length + endW) + m[4].replace(/^([=:])\s+/, "$1 ") } function alignRight(m) { - return !m[2] ? m[0] : strRepeat(startW + textW - m[2].length, " ") + m[2] - + strRepeat(endW, " ") + return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2] + + spaces(endW, " ") + m[4].replace(/^([=:])\s+/, "$1 ") } function unAlign(m) { - return !m[2] ? m[0] : strRepeat(startW, " ") + m[2] - + strRepeat(endW, " ") + return !m[2] ? m[0] : spaces(startW) + m[2] + + spaces(endW) + m[4].replace(/^([=:])\s+/, "$1 ") } }