This commit is contained in:
Alexandru Dima 2021-01-28 14:53:29 +01:00
parent 0a943766a5
commit 971fa2cc9c
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
2 changed files with 42 additions and 33 deletions

View file

@ -729,7 +729,7 @@ export class LanguageConfigurationRegistryImpl {
} else {
appendText = '';
}
} else if (indentAction === IndentAction.Indent || indentAction === IndentAction.IndentOutdent) {
} else if (indentAction === IndentAction.Indent) {
appendText = '\t' + appendText;
}

View file

@ -2812,38 +2812,6 @@ 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({
@ -4104,6 +4072,47 @@ suite('Editor Controller - Indentation Rules', () => {
mode.dispose();
});
test('issue #115304: OnEnter broken for TS', () => {
class JSMode extends MockMode {
private static readonly _id = new LanguageIdentifier('indentRulesMode', 4);
constructor() {
super(JSMode._id);
this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), {
onEnterRules: javascriptOnEnterRules
}));
}
}
const mode = new JSMode();
const model = createTextModel(
[
'/** */',
'function f() {}',
].join('\n'),
undefined,
mode.getLanguageIdentifier()
);
withTestCodeEditor(null, { model: model, autoIndent: 'advanced' }, (editor, viewModel) => {
moveTo(editor, viewModel, 1, 4, false);
assertCursor(viewModel, new Selection(1, 4, 1, 4));
viewModel.type('\n', 'keyboard');
assert.strictEqual(model.getValue(),
[
'/**',
' * ',
' */',
'function f() {}',
].join('\n')
);
assertCursor(viewModel, new Selection(2, 4, 2, 4));
});
model.dispose();
mode.dispose();
});
test('issue #38261: TAB key results in bizarre indentation in C++ mode ', () => {
class CppMode extends MockMode {
private static readonly _id = new LanguageIdentifier('indentRulesMode', 4);