@@ -80,8 +80,8 @@ export async function openKeybindingsEditor(query?: string): Promise<void> {
80
80
await vscode . commands . executeCommand ( "workbench.action.openGlobalKeybindings" , query ) ;
81
81
}
82
82
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 ) ;
85
85
const options :vscode . OpenDialogOptions = {
86
86
defaultUri,
87
87
canSelectFiles :true ,
@@ -92,8 +92,19 @@ export async function showFileSelectDialog(): Promise<vscode.Uri[] | undefined>
92
92
return await vscode . window . showOpenDialog ( options ) ;
93
93
}
94
94
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 ) ;
97
108
const options :vscode . OpenDialogOptions = {
98
109
defaultUri,
99
110
canSelectFiles :false ,