Skip to content

Commit 03213d8

Browse files
committed
Set vscode testing window back
1 parent 6ee1f7b commit 03213d8

File tree

2 files changed

+37
-48
lines changed

2 files changed

+37
-48
lines changed

packages/core/src/test/shared/vscode/message.ts

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -363,47 +363,42 @@ export class TestFileSystemDialog {
363363
fs: vscode.FileSystem,
364364
callback?: (dialog: TestFileSystemDialog) => void
365365
): Window['showOpenDialog'] {
366-
return async () => undefined
367-
368-
// return async (options?: vscode.OpenDialogOptions) => {
369-
// const dialog = new TestFileSystemDialog([], { type: 'Open', ...options })
370-
371-
// return new Promise<vscode.Uri[] | undefined>((resolve) => {
372-
// dialog.onDidAcceptItem((item) => resolve(item instanceof vscode.Uri ? [item] : item))
373-
// dialog.show()
374-
// callback?.(dialog)
375-
376-
// // Auto-close dialog in test environments to prevent hanging
377-
// setTimeout(() => {
378-
// if (dialog.visible) {
379-
// dialog.close()
380-
// }
381-
// }, 0)
382-
// })
383-
// }
366+
return async (options?: vscode.OpenDialogOptions) => {
367+
const dialog = new TestFileSystemDialog([], { type: 'Open', ...options })
368+
369+
return new Promise<vscode.Uri[] | undefined>((resolve) => {
370+
dialog.onDidAcceptItem((item) => resolve(item instanceof vscode.Uri ? [item] : item))
371+
dialog.show()
372+
callback?.(dialog)
373+
374+
// Auto-close dialog in test environments to prevent hanging
375+
setTimeout(() => {
376+
if (dialog.visible) {
377+
dialog.close()
378+
}
379+
}, 0)
380+
})
381+
}
384382
}
385383

386384
public static createShowSaveDialogFn(
387385
fs: vscode.FileSystem,
388386
callback?: (dialog: TestFileSystemDialog) => void
389387
): Window['showSaveDialog'] {
390-
return async () => undefined
391-
392-
// return async (options?: vscode.SaveDialogOptions) => {
393-
// const dialog = new TestFileSystemDialog([], { type: 'Save', ...options })
394-
395-
// return new Promise<vscode.Uri | undefined>((resolve) => {
396-
// dialog.onDidAcceptItem((item) => resolve(Array.isArray(item) ? item[0] : item))
397-
// dialog.show()
398-
// callback?.(dialog)
399-
400-
// setTimeout(() => {
401-
// if (dialog.visible) {
402-
// dialog.close()
403-
// }
404-
// }, 0)
405-
// })
406-
// }
407-
// }
388+
return async (options?: vscode.SaveDialogOptions) => {
389+
const dialog = new TestFileSystemDialog([], { type: 'Save', ...options })
390+
391+
return new Promise<vscode.Uri | undefined>((resolve) => {
392+
dialog.onDidAcceptItem((item) => resolve(Array.isArray(item) ? item[0] : item))
393+
dialog.show()
394+
callback?.(dialog)
395+
396+
setTimeout(() => {
397+
if (dialog.visible) {
398+
dialog.close()
399+
}
400+
}, 0)
401+
})
402+
}
408403
}
409404
}

packages/core/src/test/shared/vscode/window.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ export function createTestWindow(workspace = vscode.workspace): Window & TestWin
147147
emitters.onDidShowMessage.fire(message)
148148
}
149149

150-
// function fireOnDidShowDialog(dialog: TestFileSystemDialog) {
151-
// state.shownDialogs.push(dialog)
152-
// emitters.onDidShowDialog.fire(dialog)
153-
// }
150+
function fireOnDidShowDialog(dialog: TestFileSystemDialog) {
151+
state.shownDialogs.push(dialog)
152+
emitters.onDidShowDialog.fire(dialog)
153+
}
154154

155155
function fireOnDidShowQuickPick(picker: TestQuickPick) {
156156
if (!state.shownQuickPicks.includes(picker)) {
@@ -399,14 +399,8 @@ export function createTestWindow(workspace = vscode.workspace): Window & TestWin
399399
showInformationMessage: TestMessage.createShowMessageFn(SeverityLevel.Information, fireOnDidShowMessage),
400400
showWarningMessage: TestMessage.createShowMessageFn(SeverityLevel.Warning, fireOnDidShowMessage),
401401
showErrorMessage: TestMessage.createShowMessageFn(SeverityLevel.Error, fireOnDidShowMessage),
402-
showOpenDialog: async (...args) => {
403-
console.log('showOpenDialog called with args:', args)
404-
return undefined
405-
},
406-
showSaveDialog: async (...args) => {
407-
console.log('showSaveDialog called with args:', args)
408-
return undefined
409-
},
402+
showOpenDialog: TestFileSystemDialog.createOpenSaveDialogFn(workspace.fs, fireOnDidShowDialog),
403+
showSaveDialog: TestFileSystemDialog.createShowSaveDialogFn(workspace.fs, fireOnDidShowDialog),
410404
onError: onErrorEmitter.event,
411405
}
412406

0 commit comments

Comments
 (0)