Change:
Start with the following code: select the first method move it down
This reproduces for very simple examples:
See also and
Should be fixed with

Discussion:
public getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void { <ins> const getLanguageId = () => { return model.getLanguageId(); }; const getLanguageIdAtPosition = (lineNumber: number, column: number) => { return model.getLanguageIdAtPosition(lineNumber, column); }; </ins> const modelLineCount = model.getLineCount(); if (this._isMovingDown && this._selection.endLineNumber === modelLineCount) {

const { tabSize, indentSize, insertSpaces } = model.getOptions(); const indentConverter = this.buildIndentConverter(tabSize, indentSize, insertSpaces); <del> const virtualModel: IVirtualModel = { tokenization: { getLineTokens: (lineNumber: number) => { return model.tokenization.getLineTokens(lineNumber); }, getLanguageId: () => { return model.getLanguageId(); }, getLanguageIdAtPosition: (lineNumber: number, column: number) => { return model.getLanguageIdAtPosition(lineNumber, column); }, }, getLineContent: null as unknown as (lineNumber: number) => string, }; </del> if (s.startLineNumber === s.endLineNumber && model.getLineMaxColumn(s.startLineNumber) === 1) { // Current line is empty

insertingText = newIndentation + this.trimStart(movingLineText); } else { // no enter rule matches, let's check indentatin rules then. <del> virtualModel.getLineContent = (lineNumber: number) => { if (lineNumber === s.startLineNumber) { return model.getLineContent(movingLineNumber); } else { return model.getLineContent(lineNumber); } </del> <ins> const virtualModel: IVirtualModel = { tokenization: { getLineTokens: (lineNumber: number) => { if (lineNumber === s.startLineNumber) { return model.tokenization.getLineTokens(movingLineNumber); } else { return model.tokenization.getLineTokens(lineNumber); } }, getLanguageId, getLanguageIdAtPosition, }, getLineContent: (lineNumber: number) => { if (lineNumber === s.startLineNumber) { return model.getLineContent(movingLineNumber); } else { return model.getLineContent(lineNumber); } }, </ins> }; const indentOfMovingLine = getGoodIndentForLine( this._autoIndent,

} } else { // it doesn't match onEnter rules, let's check indentation rules then. <del> virtualModel.getLineContent = (lineNumber: number) => { if (lineNumber === s.startLineNumber) { return insertingText; } else if (lineNumber >= s.startLineNumber + 1 && lineNumber <= s.endLineNumber + 1) { return model.getLineContent(lineNumber - 1); } else { return model.getLineContent(lineNumber); } </del> <ins> const virtualModel: IVirtualModel = { tokenization: { getLineTokens: (lineNumber: number) => { if (lineNumber === s.startLineNumber) { return model.tokenization.getLineTokens(movingLineNumber); } else if (lineNumber >= s.startLineNumber + 1 && lineNumber <= s.endLineNumber + 1) { return model.tokenization.getLineTokens(lineNumber - 1); } else { return model.tokenization.getLineTokens(lineNumber); } }, getLanguageId, getLanguageIdAtPosition, }, getLineContent: (lineNumber: number) => { if (lineNumber === s.startLineNumber) { return insertingText; } else if (lineNumber >= s.startLineNumber + 1 && lineNumber <= s.endLineNumber + 1) { return model.getLineContent(lineNumber - 1); } else { return model.getLineContent(lineNumber); } }, </ins> }; const newIndentatOfMovingBlock = getGoodIndentForLine(

builder.addEditOperation(new Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), 'n' + movingLineText); if (this.shouldAutoIndent(model, s)) { <del> virtualModel.getLineContent = (lineNumber: number) => { if (lineNumber === movingLineNumber) { return model.getLineContent(s.startLineNumber); } else { return model.getLineContent(lineNumber); } </del> <ins> const virtualModel: IVirtualModel = { tokenization: { getLineTokens: (lineNumber: number) => { if (lineNumber === movingLineNumber) { return model.tokenization.getLineTokens(s.startLineNumber); } else { return model.tokenization.getLineTokens(lineNumber); } }, getLanguageId, getLanguageIdAtPosition, }, getLineContent: (lineNumber: number) => { if (lineNumber === movingLineNumber) { return model.getLineContent(s.startLineNumber); } else { return model.getLineContent(lineNumber); } }, </ins> }; const ret = this.matchEnterRule(model, indentConverter, tabSize, s.startLineNumber, s.startLineNumber - 2);