mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fixes #115304
This commit is contained in:
parent
0a943766a5
commit
971fa2cc9c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue