Skip to content

Commit cd88c93

Browse files
committed
adding one more test
1 parent 1f8b9de commit cd88c93

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

src/vs/editor/contrib/indentation/test/browser/indentation.test.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ import { NullState } from 'vs/editor/common/languages/nullTokenize';
1818
import { AutoIndentOnPaste, IndentationToSpacesCommand, IndentationToTabsCommand } from 'vs/editor/contrib/indentation/browser/indentation';
1919
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
2020
import { testCommand } from 'vs/editor/test/browser/testCommand';
21-
import { javascriptIndentationRules, phpIndentationRules, rubyIndentationRules } from 'vs/editor/test/common/modes/supports/indentationRules';
21+
import { goIndentationRules, javascriptIndentationRules, phpIndentationRules, rubyIndentationRules } from 'vs/editor/test/common/modes/supports/indentationRules';
2222
import { javascriptOnEnterRules, phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules';
2323

2424
enum Language {
2525
TypeScript,
2626
Ruby,
27-
PHP
27+
PHP,
28+
Go
2829
}
2930

3031
function testIndentationToSpacesCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {
@@ -81,6 +82,16 @@ function registerLanguageConfiguration(instantiationService: TestInstantiationSe
8182
onEnterRules: phpOnEnterRules
8283
}));
8384
break;
85+
case Language.Go:
86+
disposables.add(languageConfigurationService.register(languageId, {
87+
brackets: [
88+
['{', '}'],
89+
['[', ']'],
90+
['(', ')']
91+
],
92+
indentationRules: goIndentationRules
93+
}));
94+
break;
8495
}
8596
}
8697

@@ -1015,3 +1026,51 @@ suite('Auto Indent On Type - PHP', () => {
10151026
});
10161027
});
10171028
});
1029+
1030+
suite('Auto Indent On Paste - Go', () => {
1031+
1032+
const languageId = "go-test";
1033+
let disposables: DisposableStore;
1034+
1035+
setup(() => {
1036+
disposables = new DisposableStore();
1037+
});
1038+
1039+
teardown(() => {
1040+
disposables.dispose();
1041+
});
1042+
1043+
ensureNoDisposablesAreLeakedInTestSuite();
1044+
1045+
test('temp issue because there should be at least one passing test in a suite', () => {
1046+
assert.ok(true);
1047+
});
1048+
1049+
test.skip('issue #199050: should not indent after { detected in a string', () => {
1050+
1051+
// https://github.com/microsoft/vscode/issues/199050
1052+
1053+
const model = createTextModel([
1054+
'var s = `',
1055+
'quick brown',
1056+
'fox',
1057+
'`',
1058+
].join('\n'), languageId, {});
1059+
disposables.add(model);
1060+
1061+
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
1062+
registerLanguage(instantiationService, languageId, Language.Go, disposables);
1063+
editor.setSelection(new Selection(3, 1, 3, 1));
1064+
const text = ' ';
1065+
const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);
1066+
viewModel.paste(text, true, undefined, 'keyboard');
1067+
autoIndentOnPasteController.trigger(new Range(3, 1, 3, 3));
1068+
assert.strictEqual(model.getValue(), [
1069+
'var s = `',
1070+
'quick brown',
1071+
' fox',
1072+
'`',
1073+
].join('\n'));
1074+
});
1075+
});
1076+
});

src/vs/editor/test/common/modes/supports/indentationRules.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ export const phpIndentationRules = {
2121
decreaseIndentPattern: /^(.*\*\/)?\s*((\})|(\)+[;,])|(\]\)*[;,])|\b(else:)|\b((end(if|for(each)?|while|switch));))/,
2222
};
2323

24-
24+
export const goIndentationRules = {
25+
decreaseIndentPattern: /^\s*(\bcase\b.*:|\bdefault\b:|}[)}]*[),]?|\)[,]?)$/,
26+
increaseIndentPattern: /^.*(\bcase\b.*:|\bdefault\b:|(\b(func|if|else|switch|select|for|struct)\b.*)?{[^}"'`]*|\([^)"'`]*)$/,
27+
};

src/vs/editor/test/common/modes/supports/onEnterRules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const phpOnEnterRules = [
106106
},
107107
];
108108

109-
/** Note
109+
/*
110110
export enum IndentAction {
111111
None = 0,
112112
Indent = 1,

0 commit comments

Comments
 (0)