File tree
Expand file treeCollapse file tree2 files changed
+16
-5
lines changed Expand file treeCollapse file tree2 files changed
+16
-5
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -65,7 +65,7 @@ export async function testSolution(uri?: vscode.Uri): Promise<void> {
|
65 | 65 | }
|
66 | 66 | break;
|
67 | 67 | case ":file":
|
68 |
| -const testFile: vscode.Uri[] | undefined = await showFileSelectDialog(); |
| 68 | +const testFile: vscode.Uri[] | undefined = await showFileSelectDialog(filePath); |
69 | 69 | if (testFile && testFile.length) {
|
70 | 70 | const input: string = (await fse.readFile(testFile[0].fsPath, "utf-8")).trim();
|
71 | 71 | if (input) {
|
|
Original file line number | Diff line number | Diff line change |
---|
@@ -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,
|
|
You can’t perform that action at this time.
0 commit comments