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

Fixes #43722: Handle the case where the pasted text ends in \r\n

上级 227e1a2f
......@@ -124,6 +124,10 @@ export class TypeOperations {
if (text.charCodeAt(text.length - 1) === CharCode.LineFeed) {
text = text.substr(0, text.length - 1);
}
// Remove trailing \r if present
if (text.charCodeAt(text.length - 1) === CharCode.CarriageReturn) {
text = text.substr(0, text.length - 1);
}
let lines = text.split(/\r\n|\r|\n/);
if (lines.length === selections.length) {
return lines;
......
......@@ -1566,6 +1566,37 @@ suite('Editor Controller - Regression tests', () => {
});
});
test('issue #43722: Multiline paste doesn\'t work anymore', () => {
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\r\nbbb\r\nccc\r\nddd\r\n',
pasteOnNewLine: false,
multicursorText: null
});
assert.equal(model.getValue(), [
'aaa',
'bbb',
'ccc',
'ddd',
].join('\n'));
});
});
test('issue #46440: (1) Pasting a multi-line selection pastes entire selection into every insertion point', () => {
usingCursor({
text: [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册