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
1f8b9deafa
commit
cd88c93223
|
@ -18,13 +18,14 @@ import { NullState } from 'vs/editor/common/languages/nullTokenize';
|
|||
import { AutoIndentOnPaste, IndentationToSpacesCommand, IndentationToTabsCommand } from 'vs/editor/contrib/indentation/browser/indentation';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { javascriptIndentationRules, phpIndentationRules, rubyIndentationRules } from 'vs/editor/test/common/modes/supports/indentationRules';
|
||||
import { goIndentationRules, javascriptIndentationRules, phpIndentationRules, rubyIndentationRules } from 'vs/editor/test/common/modes/supports/indentationRules';
|
||||
import { javascriptOnEnterRules, phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules';
|
||||
|
||||
enum Language {
|
||||
TypeScript,
|
||||
Ruby,
|
||||
PHP
|
||||
PHP,
|
||||
Go
|
||||
}
|
||||
|
||||
function testIndentationToSpacesCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {
|
||||
|
@ -81,6 +82,16 @@ function registerLanguageConfiguration(instantiationService: TestInstantiationSe
|
|||
onEnterRules: phpOnEnterRules
|
||||
}));
|
||||
break;
|
||||
case Language.Go:
|
||||
disposables.add(languageConfigurationService.register(languageId, {
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
indentationRules: goIndentationRules
|
||||
}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1015,3 +1026,51 @@ suite('Auto Indent On Type - PHP', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Auto Indent On Paste - Go', () => {
|
||||
|
||||
const languageId = "go-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.skip('issue #199050: should not indent after { detected in a string', () => {
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/199050
|
||||
|
||||
const model = createTextModel([
|
||||
'var s = `',
|
||||
'quick brown',
|
||||
'fox',
|
||||
'`',
|
||||
].join('\n'), languageId, {});
|
||||
disposables.add(model);
|
||||
|
||||
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
|
||||
registerLanguage(instantiationService, languageId, Language.Go, disposables);
|
||||
editor.setSelection(new Selection(3, 1, 3, 1));
|
||||
const text = ' ';
|
||||
const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);
|
||||
viewModel.paste(text, true, undefined, 'keyboard');
|
||||
autoIndentOnPasteController.trigger(new Range(3, 1, 3, 3));
|
||||
assert.strictEqual(model.getValue(), [
|
||||
'var s = `',
|
||||
'quick brown',
|
||||
' fox',
|
||||
'`',
|
||||
].join('\n'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,4 +21,7 @@ export const phpIndentationRules = {
|
|||
decreaseIndentPattern: /^(.*\*\/)?\s*((\})|(\)+[;,])|(\]\)*[;,])|\b(else:)|\b((end(if|for(each)?|while|switch));))/,
|
||||
};
|
||||
|
||||
|
||||
export const goIndentationRules = {
|
||||
decreaseIndentPattern: /^\s*(\bcase\b.*:|\bdefault\b:|}[)}]*[),]?|\)[,]?)$/,
|
||||
increaseIndentPattern: /^.*(\bcase\b.*:|\bdefault\b:|(\b(func|if|else|switch|select|for|struct)\b.*)?{[^}"'`]*|\([^)"'`]*)$/,
|
||||
};
|
||||
|
|
|
@ -106,7 +106,7 @@ export const phpOnEnterRules = [
|
|||
},
|
||||
];
|
||||
|
||||
/** Note
|
||||
/*
|
||||
export enum IndentAction {
|
||||
None = 0,
|
||||
Indent = 1,
|
||||
|
|
Loading…
Reference in a new issue