do not lose cursor position while moving lines
This commit is contained in:
parent
4a8a5bad59
commit
647c713325
1 changed files with 15 additions and 5 deletions
|
|
@ -910,14 +910,24 @@ var Editor = function(renderer, session) {
|
|||
|
||||
this.$moveLines = function(mover) {
|
||||
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 selection = this.selection;
|
||||
selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
|
||||
selection.$moveSelection(function() {
|
||||
selection.moveCursorTo(rows.first+linesMoved, 0);
|
||||
});
|
||||
if (range) {
|
||||
range.start.row += linesMoved;
|
||||
range.end.row += linesMoved;
|
||||
selection.setSelectionRange(range, reverse);
|
||||
} else {
|
||||
selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
|
||||
selection.$moveSelection(function() {
|
||||
selection.moveCursorTo(rows.first+linesMoved, 0);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.$getSelectedRows = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue