@@ -6,6 +6,7 @@ import type { WorkspaceNS } from '../types'
6
6
import { Unimplemented } from '../utils/unimplemented'
7
7
import { TextDocument } from '../internal/TextDocument'
8
8
import { TextDocumentSaveReason } from '../enum/TextDocumentSaveReason'
9
+ import { WorkspaceConfiguration } from '../internal/WorkspaceConfiguration'
9
10
import type { MockVscode } from '.'
10
11
11
12
export function createMockWorkspace ( _context : MockVscode ) {
@@ -151,6 +152,49 @@ export function createMockWorkspace(_context: MockVscode) {
151
152
152
153
_onDidSaveTextDocument = new EventEmitter < TextDocument > ( )
153
154
onDidSaveTextDocument = this . _onDidSaveTextDocument . event
155
+
156
+ _onWillCreateFiles = new EventEmitter < vscode . FileWillCreateEvent > ( )
157
+ onWillCreateFiles = this . _onWillCreateFiles . event
158
+
159
+ _onDidCreateFiles = new EventEmitter < vscode . FileCreateEvent > ( )
160
+ onDidCreateFiles = this . _onDidCreateFiles . event
161
+
162
+ _onWillDeleteFiles = new EventEmitter < vscode . FileWillDeleteEvent > ( )
163
+ onWillDeleteFiles = this . _onWillDeleteFiles . event
164
+
165
+ _onDidDeleteFiles = new EventEmitter < vscode . FileDeleteEvent > ( )
166
+ onDidDeleteFiles = this . _onDidDeleteFiles . event
167
+
168
+ _onWillRenameFiles = new EventEmitter < vscode . FileWillRenameEvent > ( )
169
+ onWillRenameFiles = this . _onWillRenameFiles . event
170
+
171
+ _onDidRenameFiles = new EventEmitter < vscode . FileRenameEvent > ( )
172
+ onDidRenameFiles = this . _onDidRenameFiles . event
173
+
174
+ _workspaceConfiguration = _init . workspaceConfiguration
175
+ getConfiguration = vi . fn ( ( section ?: string , _scope ?: vscode . ConfigurationScope | null ) : WorkspaceConfiguration => {
176
+ let obj = this . _workspaceConfiguration
177
+ for ( const key of section ?. split ( '.' ) ?? [ ] ) {
178
+ if ( ! ( key in obj ) )
179
+ return new WorkspaceConfiguration ( _context , { } , section )
180
+ obj = obj [ key ]
181
+ }
182
+ return new WorkspaceConfiguration ( _context , obj , section )
183
+ } )
184
+
185
+ _onDidChangeConfiguration = new EventEmitter < vscode . ConfigurationChangeEvent > ( )
186
+ onDidChangeConfiguration = this . _onDidChangeConfiguration . event
187
+
188
+ _isTrusted = _init . isTrusted
189
+ _trust = ( ) => {
190
+ this . _isTrusted = true
191
+ this . _onDidGrantWorkspaceTrust . fire ( )
192
+ }
193
+ get isTrusted ( ) {
194
+ return this . _isTrusted
195
+ }
196
+ _onDidGrantWorkspaceTrust = new EventEmitter < void > ( )
197
+ onDidGrantWorkspaceTrust = this . _onDidGrantWorkspaceTrust . event
154
198
} ) ( )
155
199
}
156
200
@@ -163,6 +207,8 @@ export const defaultWorkspaceInitConfig = {
163
207
name : 'workspace' ,
164
208
index : 0 ,
165
209
} ] as vscode . WorkspaceFolder [ ] ,
210
+ workspaceConfiguration : { } as any ,
211
+ isTrusted : true ,
166
212
}
167
213
168
214
export type MockWorkspace = ReturnType < typeof createMockWorkspace >
0 commit comments