copy insert start position before storing it in undoStack
This commit is contained in:
parent
bacaeb07d8
commit
ffaf44ec0b
2 changed files with 23 additions and 7 deletions
|
|
@ -401,20 +401,20 @@ var Document = function(textOrLines) {
|
|||
*
|
||||
**/
|
||||
this.insertMergedLines = function(position, lines) {
|
||||
this.$clipPosition(position);
|
||||
var endPoint = {
|
||||
row : position.row + lines.length - 1,
|
||||
column : (lines.length == 1 ? position.column : 0) + lines[lines.length - 1].length
|
||||
var start = this.clippedPos(position.row, position.column);
|
||||
var end = {
|
||||
row: start.row + lines.length - 1,
|
||||
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
|
||||
};
|
||||
|
||||
this.applyDelta({
|
||||
start: position,
|
||||
end: endPoint,
|
||||
start: start,
|
||||
end: end,
|
||||
action: "insert",
|
||||
lines: lines
|
||||
});
|
||||
|
||||
return endPoint;
|
||||
return this.clonePos(end);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
require("./test/mockdom");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
|
@ -41,6 +42,7 @@ var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
|||
var Range = require("./range").Range;
|
||||
var assert = require("./test/assertions");
|
||||
var MultiSelect = require("./multi_select").MultiSelect;
|
||||
var UndoManager = require("./undomanager").UndoManager;
|
||||
|
||||
var editor;
|
||||
var exec = function(name, times, args) {
|
||||
|
|
@ -195,6 +197,20 @@ module.exports = {
|
|||
selection.fromJSON(after);
|
||||
assert.ok(!selection.isEqual(before));
|
||||
assert.ok(selection.isEqual(after));
|
||||
},
|
||||
|
||||
"test multiselect align": function() {
|
||||
var doc = new EditSession(["l1", "l2", "l3"]);
|
||||
doc.setUndoManager(new UndoManager());
|
||||
editor = new Editor(new MockRenderer(), doc);
|
||||
var selection = editor.selection;
|
||||
selection.addRange(new Range(1,0,1,0))
|
||||
selection.addRange(new Range(2,2,2,2))
|
||||
editor.execCommand("alignCursors");
|
||||
assert.equal(' l1\n l2\nl3', editor.getValue());
|
||||
doc.markUndoGroup();
|
||||
editor.execCommand("undo");
|
||||
assert.equal('l1\nl2\nl3', editor.getValue());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue