@@ -19,13 +19,14 @@ import { AutoIndentOnPaste, IndentationToSpacesCommand, IndentationToTabsCommand
19
19
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor' ;
20
20
import { testCommand } from 'vs/editor/test/browser/testCommand' ;
21
21
import { goIndentationRules , javascriptIndentationRules , phpIndentationRules , rubyIndentationRules } from 'vs/editor/test/common/modes/supports/indentationRules' ;
22
- import { javascriptOnEnterRules , phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules' ;
22
+ import { cppOnEnterRules , javascriptOnEnterRules , phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules' ;
23
23
24
24
enum Language {
25
25
TypeScript ,
26
26
Ruby ,
27
27
PHP ,
28
- Go
28
+ Go ,
29
+ CPP
29
30
}
30
31
31
32
function testIndentationToSpacesCommand ( lines : string [ ] , selection : Selection , tabSize : number , expectedLines : string [ ] , expectedSelection : Selection ) : void {
@@ -92,6 +93,16 @@ function registerLanguageConfiguration(instantiationService: TestInstantiationSe
92
93
indentationRules : goIndentationRules
93
94
} ) ) ;
94
95
break ;
96
+ case Language . CPP :
97
+ disposables . add ( languageConfigurationService . register ( languageId , {
98
+ brackets : [
99
+ [ '{' , '}' ] ,
100
+ [ '[' , ']' ] ,
101
+ [ '(' , ')' ]
102
+ ] ,
103
+ onEnterRules : cppOnEnterRules
104
+ } ) ) ;
105
+ break ;
95
106
}
96
107
}
97
108
@@ -1074,3 +1085,46 @@ suite('Auto Indent On Paste - Go', () => {
1074
1085
} ) ;
1075
1086
} ) ;
1076
1087
} ) ;
1088
+
1089
+ suite ( 'Auto Indent On Type - CPP' , ( ) => {
1090
+
1091
+ const languageId = "cpp-test" ;
1092
+ let disposables : DisposableStore ;
1093
+
1094
+ setup ( ( ) => {
1095
+ disposables = new DisposableStore ( ) ;
1096
+ } ) ;
1097
+
1098
+ teardown ( ( ) => {
1099
+ disposables . dispose ( ) ;
1100
+ } ) ;
1101
+
1102
+ ensureNoDisposablesAreLeakedInTestSuite ( ) ;
1103
+
1104
+ test ( 'temp issue because there should be at least one passing test in a suite' , ( ) => {
1105
+ assert . ok ( true ) ;
1106
+ } ) ;
1107
+
1108
+ test ( 'issue #178334: incorrect outdent of } when signature spans multiple lines' , ( ) => {
1109
+
1110
+ // https://github.com/microsoft/vscode/issues/178334
1111
+
1112
+ const model = createTextModel ( [
1113
+ 'int WINAPI WinMain(bool instance,' ,
1114
+ ' int nshowcmd) {}' ,
1115
+ ] . join ( '\n' ) , languageId , { } ) ;
1116
+ disposables . add ( model ) ;
1117
+
1118
+ withTestCodeEditor ( model , { autoIndent : "full" } , ( editor , viewModel , instantiationService ) => {
1119
+ registerLanguage ( instantiationService , languageId , Language . CPP , disposables ) ;
1120
+ editor . setSelection ( new Selection ( 2 , 20 , 2 , 20 ) ) ;
1121
+ viewModel . type ( "\n" , 'keyboard' ) ;
1122
+ assert . strictEqual ( model . getValue ( ) , [
1123
+ 'int WINAPI WinMain(bool instance,' ,
1124
+ ' int nshowcmd) {' ,
1125
+ ' ' ,
1126
+ '}'
1127
+ ] . join ( '\n' ) ) ;
1128
+ } ) ;
1129
+ } ) ;
1130
+ } ) ;
0 commit comments