@@ -80,8 +80,8 @@ export async function openKeybindingsEditor(query?: string): Promise<void> {
8080 await vscode . commands . executeCommand ( "workbench.action.openGlobalKeybindings" , query ) ;
8181}
8282
83- export async function showFileSelectDialog ( ) : Promise < vscode . Uri [ ] | undefined > {
84- const defaultUri : vscode . Uri | undefined = vscode . workspace . rootPath ? vscode . Uri . file ( vscode . workspace . rootPath ) : undefined ;
83+ export async function showFileSelectDialog ( fsPath ?: string ) : Promise < vscode . Uri [ ] | undefined > {
84+ const defaultUri : vscode . Uri | undefined = getBelongingWorkspaceFolderUri ( fsPath ) ;
8585 const options : vscode . OpenDialogOptions = {
8686 defaultUri,
8787 canSelectFiles : true ,
@@ -92,8 +92,19 @@ export async function showFileSelectDialog(): Promise<vscode.Uri[] | undefined>
9292 return await vscode . window . showOpenDialog ( options ) ;
9393}
9494
95- export async function showDirectorySelectDialog ( ) : Promise < vscode . Uri [ ] | undefined > {
96- const defaultUri : vscode . Uri | undefined = vscode . workspace . rootPath ? vscode . Uri . file ( vscode . workspace . rootPath ) : undefined ;
95+ function getBelongingWorkspaceFolderUri ( fsPath : string | undefined ) : vscode . Uri | undefined {
96+ let defaultUri : vscode . Uri | undefined ;
97+ if ( fsPath ) {
98+ const workspaceFolder : vscode . WorkspaceFolder | undefined = vscode . workspace . getWorkspaceFolder ( vscode . Uri . file ( fsPath ) ) ;
99+ if ( workspaceFolder ) {
100+ defaultUri = workspaceFolder . uri ;
101+ }
102+ }
103+ return defaultUri ;
104+ }
105+ 106+ export async function showDirectorySelectDialog ( fsPath ?: string ) : Promise < vscode . Uri [ ] | undefined > {
107+ const defaultUri : vscode . Uri | undefined = getBelongingWorkspaceFolderUri ( fsPath ) ;
97108 const options : vscode . OpenDialogOptions = {
98109 defaultUri,
99110 canSelectFiles : false ,
0 commit comments