提交 beb6a213 编写于 作者: A Alex Dima

Distribute paste to multiple cursors only if it originated with the same...

Distribute paste to multiple cursors only if it originated with the same number of multiple cursors (fixes #16155)
上级 e07bba8d
......@@ -122,18 +122,7 @@ export class TypeOperations {
return multicursorText;
}
for (let i = 0; i < selections.length; i++) {
if (selections[i].startLineNumber !== selections[i].endLineNumber) {
return null;
}
}
let pastePieces = text.split(/\r\n|\r|\n/);
if (pastePieces.length !== selections.length) {
return null;
}
return pastePieces;
return null;
}
public static paste(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): EditOperationResult {
......
......@@ -27,7 +27,13 @@ suite('Multicursor', () => {
addCursorUpAction.run(null, editor, {});
assert.equal(cursor.getSelections().length, 2);
editor.trigger('test', Handler.Paste, { text: '1\n2' });
editor.trigger('test', Handler.Paste, {
text: '1\n2',
multicursorText: [
'1',
'2'
]
});
// cursorCommand(cursor, H.Paste, { text: '1\n2' });
assert.equal(editor.getModel().getLineContent(1), '1abc');
assert.equal(editor.getModel().getLineContent(2), '2def');
......
......@@ -1447,6 +1447,49 @@ suite('Editor Controller - Regression tests', () => {
});
});
test('issue #16155: Paste into multiple cursors has edge case when number of lines equals number of cursors - 1', () => {
usingCursor({
text: [
'test',
'test',
'test',
'test'
],
}, (model, cursor) => {
cursor.setSelections('test', [
new Selection(1, 1, 1, 5),
new Selection(2, 1, 2, 5),
new Selection(3, 1, 3, 5),
new Selection(4, 1, 4, 5),
]);
cursorCommand(cursor, H.Paste, {
text: 'aaa\nbbb\nccc\n',
pasteOnNewLine: false,
multicursorText: null
});
assert.equal(model.getValue(), [
'aaa',
'bbb',
'ccc',
'',
'aaa',
'bbb',
'ccc',
'',
'aaa',
'bbb',
'ccc',
'',
'aaa',
'bbb',
'ccc',
'',
].join('\n'));
});
});
test('issue #3071: Investigate why undo stack gets corrupted', () => {
let model = Model.createFromString(
[
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册