@@ -11,7 +11,6 @@ import {
1111 closeAllEditorsAsync ,
1212 openFileInWorkspaceAsync ,
1313 revertActiveFile ,
14- sleep ,
1514 waitForExpectedResult ,
1615} from './integrationHelpers' ;
1716import { describe , beforeAll , beforeEach , afterAll , test , expect , afterEach } from '@jest/globals' ;
@@ -36,7 +35,6 @@ describe(`OnAutoInsert Tests`, () => {
3635 } ) ;
3736
3837 test ( 'Triple slash inserts doc comment snippet' , async ( ) => {
39- await sleep ( 1 ) ;
4038 await vscode . window . activeTextEditor ! . edit ( ( editBuilder ) => {
4139 editBuilder . insert ( new vscode . Position ( 2 , 6 ) , '/' ) ;
4240 } ) ;
@@ -123,22 +121,17 @@ describe(`OnAutoInsert Tests`, () => {
123121 const originalCsharpTabSize = csharpConfig . get ( 'tabSize' ) ;
124122
125123 try {
126- // Configure global tabSize to 2
127- await globalConfig . update ( 'tabSize' , 2 , vscode . ConfigurationTarget . Global ) ;
128- // Configure C# tabSize to 4
129- await vscode . workspace
130- . getConfiguration ( '[csharp]' , vscode . window . activeTextEditor ! . document . uri )
131- . update ( 'editor.tabSize' , 4 , vscode . ConfigurationTarget . Global ) ;
124+ // Turn off detect indentation to ensure it consistently uses the settings.
125+ await globalConfig . update ( 'detectIndentation' , false , vscode . ConfigurationTarget . Global ) ;
132126
133- // Wait for configuration to propagate
134- await sleep ( 100 ) ;
127+ // Customize tab sizes
128+ await globalConfig . update ( 'tabSize' , 4 , vscode . ConfigurationTarget . Global ) ;
129+ await csharpConfig . update ( 'tabSize' , 2 , vscode . ConfigurationTarget . Global ) ;
135130
136131 await vscode . window . activeTextEditor ! . edit ( ( editBuilder ) => {
137132 editBuilder . insert ( new vscode . Position ( 11 , 15 ) , '\n' ) ;
138133 } ) ;
139134
140- // OnAutoInsert is triggered by the change event but completes asynchronously, so wait for the buffer to be updated.
141-
142135 const expectedLines = [
143136 'class DocComments' ,
144137 '{' ,
@@ -152,9 +145,9 @@ describe(`OnAutoInsert Tests`, () => {
152145 '' ,
153146 ' /// </summary>' ,
154147 ' void M2()' ,
155- ' {' ,
156- ' ' , // Should be 4 spaces (C# setting), not 2 (global setting)
157- ' }' ,
148+ ' {' ,
149+ ' ' , // Should be 2 spaces (C# setting), not 4 (global setting)
150+ ' }' ,
158151 '}' ,
159152 '' ,
160153 ] ;
@@ -169,10 +162,9 @@ describe(`OnAutoInsert Tests`, () => {
169162 ) ;
170163 } finally {
171164 // Restore original settings
165+ await globalConfig . update ( 'detectIndentation' , true , vscode . ConfigurationTarget . Global ) ;
172166 await globalConfig . update ( 'tabSize' , originalGlobalTabSize , vscode . ConfigurationTarget . Global ) ;
173- await vscode . workspace
174- . getConfiguration ( '[csharp]' , vscode . window . activeTextEditor ! . document . uri )
175- . update ( 'editor.tabSize' , originalCsharpTabSize , vscode . ConfigurationTarget . Global ) ;
167+ await csharpConfig . update ( 'tabSize' , originalCsharpTabSize , vscode . ConfigurationTarget . Global ) ;
176168 }
177169 } ) ;
178170} ) ;
0 commit comments