@@ -133,7 +133,7 @@ function isTextModel(arg: ITextModel | string | string[] | ITextBufferFactory):
133
133
134
134
function _withTestCodeEditor ( arg : ITextModel | string | string [ ] | ITextBufferFactory , options : TestCodeEditorInstantiationOptions , callback : ( editor : ITestCodeEditor , viewModel : ViewModel , instantiationService : TestInstantiationService ) => void ) : void ;
135
135
function _withTestCodeEditor ( arg : ITextModel | string | string [ ] | ITextBufferFactory , options : TestCodeEditorInstantiationOptions , callback : ( editor : ITestCodeEditor , viewModel : ViewModel , instantiationService : TestInstantiationService ) => Promise < void > ) : Promise < void > ;
136
- function _withTestCodeEditor ( arg : ITextModel | string | string [ ] | ITextBufferFactory , options : TestCodeEditorInstantiationOptions , callback : ( editor : ITestCodeEditor , viewModel : ViewModel , instantiationService : TestInstantiationService ) => Promise < void > | void ) : Promise < void > | void {
136
+ async function _withTestCodeEditor ( arg : ITextModel | string | string [ ] | ITextBufferFactory , options : TestCodeEditorInstantiationOptions , callback : ( editor : ITestCodeEditor , viewModel : ViewModel , instantiationService : TestInstantiationService ) => Promise < void > | void ) : Promise < Promise < void > | void > {
137
137
const disposables = new DisposableStore ( ) ;
138
138
const instantiationService = createCodeEditorServices ( disposables , options . serviceCollection ) ;
139
139
delete options . serviceCollection ;
@@ -149,12 +149,12 @@ function _withTestCodeEditor(arg: ITextModel | string | string[] | ITextBufferFa
149
149
const editor = disposables . add ( instantiateTestCodeEditor ( instantiationService , model , options ) ) ;
150
150
const viewModel = editor . getViewModel ( ) ! ;
151
151
viewModel . setHasFocus ( true ) ;
152
- const result = callback ( < ITestCodeEditor > editor , editor . getViewModel ( ) ! , instantiationService ) ;
153
- if ( result ) {
154
- return result . then ( ( ) => disposables . dispose ( ) ) ;
152
+ try {
153
+ const result = callback ( < ITestCodeEditor > editor , editor . getViewModel ( ) ! , instantiationService ) ;
154
+ await result ;
155
+ } finally {
156
+ disposables . dispose ( ) ;
155
157
}
156
-
157
- disposables . dispose ( ) ;
158
158
}
159
159
160
160
export function createCodeEditorServices ( disposables : DisposableStore , services : ServiceCollection = new ServiceCollection ( ) ) : TestInstantiationService {
0 commit comments