From 7375b669ffa173ba037535ed8b66669a7e617eb1 Mon Sep 17 00:00:00 2001 From: Gorniaky Date: Thu, 15 Oct 2026 14:01:32 -0300 Subject: [PATCH] refactor: update getFolderDialog to use OpenFolderDialogOptions and remove deprecated parameters --- src/utils/FileSystem.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/utils/FileSystem.ts b/src/utils/FileSystem.ts index dbf52cd0..1dbb4230 100644 --- a/src/utils/FileSystem.ts +++ b/src/utils/FileSystem.ts @@ -1,6 +1,6 @@ import { t } from "@vscode/l10n"; import { dirname, join } from "path"; -import { commands, env, FileType, Uri, window, workspace, type CancellationToken } from "vscode"; +import { commands, env, FileType, Uri, window, workspace, type CancellationToken, type OpenDialogOptions } from "vscode"; import type { GetWorkspaceFolderOptions, TaskData } from "../@types"; import { BLOCKED_FILES } from "./constants"; import lazy from "./lazy"; @@ -23,6 +23,8 @@ export interface FileSystemOptions { ignoreList?: string[] } +export type OpenFolderDialogOptions = Omit + export default class FileSystem { static get singleWorkspaceFolder() { const folders = workspace.workspaceFolders; @@ -33,20 +35,6 @@ export default class FileSystem { return Boolean(workspace.workspaceFolders?.length); } - static async getFolderDialog(task?: TaskData | null, title?: string, openLabel?: string) { - task?.progress.report({ increment: -1, message: t("folder.get.one") }); - - const uris = await window.showOpenDialog({ - canSelectFolders: true, - title, - openLabel, - }); - - if (uris?.length) task?.progress.report({ message: t("folder.selected") }); - - return uris?.at(0); - } - static async findIgnoreFile(filename: string, ignoreList?: string | string[] | Set, token?: CancellationToken) { if (!ignoreList) ignoreList = lazyDefaultBlockedFilesPattern(); @@ -79,6 +67,21 @@ export default class FileSystem { return Array.from(result); } + static async getFolderDialog(task?: TaskData | null, options?: OpenFolderDialogOptions) { + task?.progress.report({ increment: -1, message: t("folder.get.one") }); + + const uris = await window.showOpenDialog({ + canSelectFiles: false, + canSelectFolders: true, + canSelectMany: false, + ...options, + }); + + if (uris?.length) task?.progress.report({ message: t("folder.selected") }); + + return uris?.at(0); + } + static async getWorkspaceFolder(options?: GetWorkspaceFolderOptions | null): Promise { options ??= {};