Fixes #115148: Indent new line when using `IndentOutdent` and `appendText`

pull/115253/head
Alexandru Dima 2021-01-27 16:50:11 +01:00
parent e4f1833d79
commit ff27ea9437
No known key found for this signature in database
GPG Key ID: 6E58D7B045760DA0
2 changed files with 33 additions and 1 deletions

View File

@ -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;
}

View File

@ -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({