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.insertMergedLines = function(position, lines) {
|
||||||
this.$clipPosition(position);
|
var start = this.clippedPos(position.row, position.column);
|
||||||
var endPoint = {
|
var end = {
|
||||||
row : position.row + lines.length - 1,
|
row: start.row + lines.length - 1,
|
||||||
column : (lines.length == 1 ? position.column : 0) + lines[lines.length - 1].length
|
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
|
||||||
};
|
};
|
||||||
|
|
||||||
this.applyDelta({
|
this.applyDelta({
|
||||||
start: position,
|
start: start,
|
||||||
end: endPoint,
|
end: end,
|
||||||
action: "insert",
|
action: "insert",
|
||||||
lines: lines
|
lines: lines
|
||||||
});
|
});
|
||||||
|
|
||||||
return endPoint;
|
return this.clonePos(end);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
if (typeof process !== "undefined") {
|
if (typeof process !== "undefined") {
|
||||||
require("amd-loader");
|
require("amd-loader");
|
||||||
|
require("./test/mockdom");
|
||||||
}
|
}
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
@ -41,6 +42,7 @@ var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||||
var Range = require("./range").Range;
|
var Range = require("./range").Range;
|
||||||
var assert = require("./test/assertions");
|
var assert = require("./test/assertions");
|
||||||
var MultiSelect = require("./multi_select").MultiSelect;
|
var MultiSelect = require("./multi_select").MultiSelect;
|
||||||
|
var UndoManager = require("./undomanager").UndoManager;
|
||||||
|
|
||||||
var editor;
|
var editor;
|
||||||
var exec = function(name, times, args) {
|
var exec = function(name, times, args) {
|
||||||
|
|
@ -195,6 +197,20 @@ module.exports = {
|
||||||
selection.fromJSON(after);
|
selection.fromJSON(after);
|
||||||
assert.ok(!selection.isEqual(before));
|
assert.ok(!selection.isEqual(before));
|
||||||
assert.ok(selection.isEqual(after));
|
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