Skip to content

Commit

Permalink
Use new argument syntax for openFolder built-in command
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Sep 17, 2024
1 parent 03a78bd commit 9c6868c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
22 changes: 13 additions & 9 deletions src/webview/newMicroPythonProjectPanel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,16 @@ export class NewMicroPythonProjectPanel {
if (!settings) {
panel.dispose();

// TODO: maybe add restart button
void window.showErrorMessage(
"Failed to load settings. Please restart VSCode."
);
void window
.showErrorMessage(
"Failed to load settings. Please restart VS Code or reload the window.",
"Reload Window"
)
.then(selected => {
if (selected === "Reload Window") {
commands.executeCommand("workbench.action.reloadWindow");
}
});

return;
}
Expand Down Expand Up @@ -354,11 +360,9 @@ print("Finished.")\r\n`;
await new Promise(resolve => setTimeout(resolve, 2000));

// open and call initialise
void commands.executeCommand(
"vscode.openFolder",
Uri.file(projectFolder),
(workspace.workspaceFolders?.length ?? 0) > 0
);
void commands.executeCommand("vscode.openFolder", Uri.file(projectFolder), {
forceNewWindow: (workspace.workspaceFolders?.length ?? 0) > 0,
});
}

private async _update(): Promise<void> {
Expand Down
18 changes: 13 additions & 5 deletions src/webview/newProjectPanel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,16 @@ export class NewProjectPanel {
if (settings === undefined) {
panel.dispose();

// TODO: maybe add restart button
void window.showErrorMessage(
"Failed to load settings. Please restart VSCode."
);
void window
.showErrorMessage(
"Failed to load settings. Please restart VS Code or reload the window.",
"Reload Window"
)
.then(selected => {
if (selected === "Reload Window") {
commands.executeCommand("workbench.action.reloadWindow");
}
});

return;
}
Expand Down Expand Up @@ -2230,7 +2236,9 @@ export class NewProjectPanel {
? options.projectRoot
: join(options.projectRoot, projectName)
),
(workspace.workspaceFolders?.length ?? 0) > 0
{
forceNewWindow: (workspace.workspaceFolders?.length ?? 0) > 0,
}
);

// restart the extension if the folder was already open cause then vscode won't
Expand Down

0 comments on commit 9c6868c

Please sign in to comment.