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

Fixes #15118: Trim auto whitespace when inserting a new line before

上级 8bec9ea2
......@@ -1213,6 +1213,14 @@ export class TextModel extends Disposable implements model.ITextModel {
continue;
}
if (
trimLineNumber === editRange.startLineNumber && editRange.startColumn === 1
&& editRange.isEmpty() && editText && editText.length > 0 && editText.charAt(editText.length - 1) === '\n'
) {
// This edit inserts a new line (and maybe other text) before `trimLine`
continue;
}
// Looks like we can't trim this line as it would interfere with an incoming edit
allowTrimLine = false;
break;
......
......@@ -2485,6 +2485,45 @@ suite('Editor Controller - Cursor Configuration', () => {
model.dispose();
});
test('issue #15118: remove auto whitespace when pasting entire line', () => {
let model = createTextModel(
[
' function f() {',
' // I\'m gonna copy this line',
' return 3;',
' }',
].join('\n')
);
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
moveTo(cursor, 3, model.getLineMaxColumn(3));
cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard');
assert.equal(model.getValue(), [
' function f() {',
' // I\'m gonna copy this line',
' return 3;',
' ',
' }',
].join('\n'));
assertCursor(cursor, new Position(4, model.getLineMaxColumn(4)));
cursorCommand(cursor, H.Paste, { text: ' // I\'m gonna copy this line\n', pasteOnNewLine: true });
assert.equal(model.getValue(), [
' function f() {',
' // I\'m gonna copy this line',
' return 3;',
' // I\'m gonna copy this line',
'',
' }',
].join('\n'));
assertCursor(cursor, new Position(5, 1));
});
model.dispose();
});
test('UseTabStops is off', () => {
let model = createTextModel(
[
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册