diff --git a/src/vs/editor/common/modes/languageConfigurationRegistry.ts b/src/vs/editor/common/modes/languageConfigurationRegistry.ts index 6074e34cc22..8f42df68d9d 100644 --- a/src/vs/editor/common/modes/languageConfigurationRegistry.ts +++ b/src/vs/editor/common/modes/languageConfigurationRegistry.ts @@ -729,7 +729,7 @@ export class LanguageConfigurationRegistryImpl { } else { appendText = ''; } - } else if (indentAction === IndentAction.Indent) { + } else if (indentAction === IndentAction.Indent || indentAction === IndentAction.IndentOutdent) { appendText = '\t' + appendText; } diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index 5b3dcecfe87..1bb64e4d511 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -2812,6 +2812,38 @@ suite('Editor Controller - Cursor Configuration', () => { mode.dispose(); }); + test('issue #115148: indentOutdent and appendText', () => { + const mode = new class extends MockMode { + constructor() { + super(new LanguageIdentifier('onEnterMode', 3)); + this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), { + onEnterRules: [{ + beforeText: /.*/, + action: { + indentAction: IndentAction.IndentOutdent, + appendText: 'x' + } + }] + })); + } + }(); + usingCursor({ + text: [ + 'text {}' + ], + languageIdentifier: mode.getLanguageIdentifier(), + }, (editor, model, viewModel) => { + + moveTo(editor, viewModel, 1, 7); + viewModel.type('\n', 'keyboard'); + assert.strictEqual(model.getLineContent(1), 'text {'); + assert.strictEqual(model.getLineContent(2), ' x'); + assert.strictEqual(model.getLineContent(3), '}'); + assertCursor(viewModel, new Position(2, 6)); + }); + mode.dispose(); + }); + test('issue #6862: Editor removes auto inserted indentation when formatting on type', () => { let mode = new OnEnterMode(IndentAction.IndentOutdent); usingCursor({