@@ -18,13 +18,14 @@ import { NullState } from 'vs/editor/common/languages/nullTokenize';
18
18
import { AutoIndentOnPaste , IndentationToSpacesCommand , IndentationToTabsCommand } from 'vs/editor/contrib/indentation/browser/indentation' ;
19
19
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor' ;
20
20
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' ;
22
22
import { javascriptOnEnterRules , phpOnEnterRules } from 'vs/editor/test/common/modes/supports/onEnterRules' ;
23
23
24
24
enum Language {
25
25
TypeScript ,
26
26
Ruby ,
27
- PHP
27
+ PHP ,
28
+ Go
28
29
}
29
30
30
31
function testIndentationToSpacesCommand ( lines : string [ ] , selection : Selection , tabSize : number , expectedLines : string [ ] , expectedSelection : Selection ) : void {
@@ -81,6 +82,16 @@ function registerLanguageConfiguration(instantiationService: TestInstantiationSe
81
82
onEnterRules : phpOnEnterRules
82
83
} ) ) ;
83
84
break ;
85
+ case Language . Go :
86
+ disposables . add ( languageConfigurationService . register ( languageId , {
87
+ brackets : [
88
+ [ '{' , '}' ] ,
89
+ [ '[' , ']' ] ,
90
+ [ '(' , ')' ]
91
+ ] ,
92
+ indentationRules : goIndentationRules
93
+ } ) ) ;
94
+ break ;
84
95
}
85
96
}
86
97
@@ -1015,3 +1026,51 @@ suite('Auto Indent On Type - PHP', () => {
1015
1026
} ) ;
1016
1027
} ) ;
1017
1028
} ) ;
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
+ } ) ;
0 commit comments