Yesss fix positional bug

This commit is contained in:
Garen Torikian 2012-12-15 12:16:22 -08:00 • committed by nightwing
commit face772865

View file

@ -46,6 +46,7 @@ var ElasticTabstops = function(editor, session) {
if (checkedRows.indexOf(row) > -1) if (checkedRows.indexOf(row) > -1)
continue; continue;
var cellWidthObj = this.$findCellWidthsForBlock(row); var cellWidthObj = this.$findCellWidthsForBlock(row);
var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths); var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);
var rowIndex = cellWidthObj.firstRow; var rowIndex = cellWidthObj.firstRow;
@ -113,9 +114,13 @@ var ElasticTabstops = function(editor, session) {
}; };
this.$selectionColumnsForRow = function(row) { this.$selectionColumnsForRow = function(row) {
var selections = []; var selections = [], cursor = this.$editor.getCursorPosition();
// todo: support multicursor if (this.$session.getSelection().isEmpty()) {
selections.push(this.$editor.getCursorPosition().column + 1); // todo: support multicursor
if (row == cursor.row)
selections.push(cursor.column);
}
return selections; return selections;
}; };
@ -192,7 +197,7 @@ var ElasticTabstops = function(editor, session) {
// this always only contains two elements, so we're safe in the loop below // this always only contains two elements, so we're safe in the loop below
var expandedSet = this.$izip(widths, rowTabs); var expandedSet = this.$izip(widths, rowTabs);
for (var i = 0, l = expandedSet.length; i < l; i++) { for (var i = 0, l = expandedSet.length; i < l; i++) {
var w = expandedSet[i][0], it = expandedSet[i][1]; var w = expandedSet[i][0], it = expandedSet[i][1];
location += 1 + w; location += 1 + w;
@ -202,7 +207,7 @@ var ElasticTabstops = function(editor, session) {
if (difference == 0) if (difference == 0)
continue; continue;
var partialLine = this.$session.getLine(row).substr(0, it); var partialLine = this.$session.getLine(row).substr(0, it );
var strippedPartialLine = partialLine.replace(/\s*$/g, ""); var strippedPartialLine = partialLine.replace(/\s*$/g, "");
var ispaces = partialLine.length - strippedPartialLine.length; var ispaces = partialLine.length - strippedPartialLine.length;
@ -216,7 +221,7 @@ var ElasticTabstops = function(editor, session) {
} }
if (difference < 0 && ispaces >= -difference) { if (difference < 0 && ispaces >= -difference) {
this.$session.getDocument().removeInLine(row, it, it + difference); this.$session.getDocument().removeInLine(row, it + difference, it);
bias += difference; bias += difference;
} }
} }