mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
adding one more test
This commit is contained in:
parent
cd88c93223
commit
9978dd8687
|
@ -19,13 +19,14 @@ import { AutoIndentOnPaste, IndentationToSpacesCommand, IndentationToTabsCommand
|
|||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { goIndentationRules, javascriptIndentationRules, phpIndentationRules, rubyIndentationRules } from 'vs/editor/test/common/modes/supports/indentationRules';
|
||||
import { javascriptOnEnterRules, phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules';
|
||||
import { cppOnEnterRules, javascriptOnEnterRules, phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules';
|
||||
|
||||
enum Language {
|
||||
TypeScript,
|
||||
Ruby,
|
||||
PHP,
|
||||
Go
|
||||
Go,
|
||||
CPP
|
||||
}
|
||||
|
||||
function testIndentationToSpacesCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {
|
||||
|
@ -92,6 +93,16 @@ function registerLanguageConfiguration(instantiationService: TestInstantiationSe
|
|||
indentationRules: goIndentationRules
|
||||
}));
|
||||
break;
|
||||
case Language.CPP:
|
||||
disposables.add(languageConfigurationService.register(languageId, {
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
onEnterRules: cppOnEnterRules
|
||||
}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1074,3 +1085,46 @@ suite('Auto Indent On Paste - Go', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Auto Indent On Type - CPP', () => {
|
||||
|
||||
const languageId = "cpp-test";
|
||||
let disposables: DisposableStore;
|
||||
|
||||
setup(() => {
|
||||
disposables = new DisposableStore();
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
test('temp issue because there should be at least one passing test in a suite', () => {
|
||||
assert.ok(true);
|
||||
});
|
||||
|
||||
test('issue #178334: incorrect outdent of } when signature spans multiple lines', () => {
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/178334
|
||||
|
||||
const model = createTextModel([
|
||||
'int WINAPI WinMain(bool instance,',
|
||||
' int nshowcmd) {}',
|
||||
].join('\n'), languageId, {});
|
||||
disposables.add(model);
|
||||
|
||||
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
|
||||
registerLanguage(instantiationService, languageId, Language.CPP, disposables);
|
||||
editor.setSelection(new Selection(2, 20, 2, 20));
|
||||
viewModel.type("\n", 'keyboard');
|
||||
assert.strictEqual(model.getValue(), [
|
||||
'int WINAPI WinMain(bool instance,',
|
||||
' int nshowcmd) {',
|
||||
' ',
|
||||
'}'
|
||||
].join('\n'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -106,6 +106,16 @@ export const phpOnEnterRules = [
|
|||
},
|
||||
];
|
||||
|
||||
export const cppOnEnterRules = [
|
||||
{
|
||||
previousLineText: /^\s*(((else ?)?if|for|while)\s*\(.*\)\s*|else\s*)$/,
|
||||
beforeText: /^\s+([^{i\s]|i(?!f\b))/,
|
||||
action: {
|
||||
indentAction: IndentAction.Outdent
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
/*
|
||||
export enum IndentAction {
|
||||
None = 0,
|
||||
|
|
Loading…
Reference in a new issue