do not lose cursor position while moving lines

This commit is contained in:
nightwing 2011-11-08 10:44:26 +04:00
commit 647c713325

View file

@ -910,14 +910,24 @@ var Editor = function(renderer, session) {
this.$moveLines = function(mover) { this.$moveLines = function(mover) {
var rows = this.$getSelectedRows(); var rows = this.$getSelectedRows();
var selection = this.selection;
if (!selection.isMultiLine()) {
var range = selection.getRange();
var reverse = selection.isBackwards();
}
var linesMoved = mover.call(this, rows.first, rows.last); var linesMoved = mover.call(this, rows.first, rows.last);
var selection = this.selection; if (range) {
selection.setSelectionAnchor(rows.last+linesMoved+1, 0); range.start.row += linesMoved;
selection.$moveSelection(function() { range.end.row += linesMoved;
selection.moveCursorTo(rows.first+linesMoved, 0); selection.setSelectionRange(range, reverse);
}); } else {
selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
selection.$moveSelection(function() {
selection.moveCursorTo(rows.first+linesMoved, 0);
});
}
}; };
this.$getSelectedRows = function() { this.$getSelectedRows = function() {