Make a better multipler

This commit is contained in:
Garen Torikian 2012-12-12 17:01:07 -08:00 committed by nightwing
commit 4d94636247

View file

@ -947,18 +947,9 @@ var Editor = function(renderer, session) {
var ispaces = partialLine.length - strippedPartialLine.length;
if (difference > 0) {
// some Kris Kowal code to multiply strings
var acc = [], str = " ";
for (var i = 0; (1 << i) <= difference; i++) {
if ((1 << i) & difference)
acc.push(str);
str += str;
}
acc = acc.join("");
// put the spaces after the tab and then delete the tab, so any insertion
// points behave as expected
this.session.getDocument().insertInLine({row: row, column: it + 1}, acc + "\t");
this.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference).join(" ") + "\t");
this.session.getDocument().removeInLine(row, it, it + 1);
bias += difference;
@ -971,24 +962,6 @@ var Editor = function(renderer, session) {
}
};
// gets the text point of the character from the start of the document
this.textPoint = function(row, col) {
var selRange = new Range(0, 0, row, col);
var text = this.session.getTextRange(selRange);
return text.length;
};
// gets the range of a character, from the start of its row to the given column
this.lineRange = function(col) {
var selRange = new Range(0, 0, row, 0);
var text = this.session.getTextRange(selRange);
return { start: text.length, end: text.length + col };
};
// the is a (naive) Python port--but works for these purposes
this.$izip_longest = function(iterables) {
var longest = iterables[0].length;