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();
if (this.$session.getSelection().isEmpty()) {
// todo: support multicursor // todo: support multicursor
selections.push(this.$editor.getCursorPosition().column + 1); if (row == cursor.row)
selections.push(cursor.column);
}
return selections; return selections;
}; };
@ -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;
} }
} }