Skip to content

Commit 01cbc17

Browse files
authored
Merge pull request #12967 from quarto-dev/workbench-no-open
create - force `--no-open` when inside Posit Workbench
2 parents 7320e5d + 49f6f9e commit 01cbc17

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

news/changelog-1.8.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ All changes included in 1.8:
7979

8080
- ([#12627](https://github.com/quarto-dev/quarto-cli/issues/12627)): Don't actually install extension when user responds `yes` to first prompt but `no` to second.
8181

82+
### `create`
83+
84+
- ([#12965](https://github.com/quarto-dev/quarto-cli/issues/12965)): Prevent automatic opening of new editor sessions when creating projects in Posit Workbench context. The `--open` flag is now ignored in this environment to avoid issues with Workbench session management.
85+
8286
## Engines
8387

8488
### `jupyter`

src/command/create/cmd.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { extensionArtifactCreator } from "./artifacts/extension.ts";
88
import { projectArtifactCreator } from "./artifacts/project.ts";
99
import { kEditorInfos, scanForEditors } from "./editor.ts";
1010

11-
import { isInteractiveTerminal } from "../../core/platform.ts";
11+
import {
12+
isInteractiveTerminal,
13+
isPositWorkbench,
14+
} from "../../core/platform.ts";
1215
import { runningInCI } from "../../core/ci-info.ts";
1316

1417
import { Command } from "cliffy/command/mod.ts";
@@ -56,6 +59,16 @@ export const createCommand = new Command()
5659
const isInteractive = isInteractiveTerminal() && !runningInCI();
5760
const allowPrompt = isInteractive && !!options.prompt && !options.json;
5861

62+
// Specific case where opening automatically in an editor is not allowed
63+
if (options.open !== false && isPositWorkbench()) {
64+
if (options.open !== undefined) {
65+
info(
66+
`The --open option is not supported in Posit Workbench - ignoring`,
67+
);
68+
}
69+
options.open = false;
70+
}
71+
5972
// Resolve the type into an artifact
6073
const resolved = await resolveArtifact(
6174
type,

src/command/preview/preview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ import {
7676
safeExistsSync,
7777
} from "../../core/path.ts";
7878
import {
79+
isPositWorkbench,
7980
isRStudio,
80-
isRStudioWorkbench,
8181
isServerSession,
8282
isVSCodeServer,
8383
vsCodeServerProxyUri,
@@ -872,7 +872,7 @@ function pdfFileRequestHandler(
872872
const onRequest = pdfOptions.onRequest;
873873
pdfOptions.onRequest = async (req: Request) => {
874874
if (new URL(req.url).pathname === "/") {
875-
const url = isRStudioWorkbench()
875+
const url = isPositWorkbench()
876876
? await rswURL(port, kPdfJsInitialPath)
877877
: isVSCodeServer()
878878
? vsCodeServerProxyUri()!.replace("{{port}}", `${port}`) +

src/core/platform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function isVSCodeServer() {
3434
return !!vsCodeServerProxyUri();
3535
}
3636

37-
export function isRStudioWorkbench() {
37+
export function isPositWorkbench() {
3838
// RS_SERVER_URL e.g. https://daily-rsw.soleng.rstudioservices.com/
3939
// RS_SESSION_URL e.g. /s/eae053c9ab5a71168ee19/
4040
return !!Deno.env.get("RS_SERVER_URL") && !!Deno.env.get("RS_SESSION_URL");
@@ -50,7 +50,7 @@ export function isPositronTerminal() {
5050
}
5151

5252
export function isServerSession() {
53-
return isRStudioServer() || isRStudioWorkbench() || isJupyterServer() ||
53+
return isRStudioServer() || isPositWorkbench() || isJupyterServer() ||
5454
isJupyterHubServer() || isVSCodeServer();
5555
}
5656

src/core/previewurl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import * as colors from "fmt/colors";
1010
import {
1111
isJupyterHubServer,
1212
isJupyterServer,
13+
isPositWorkbench,
1314
isRStudioServer,
14-
isRStudioWorkbench,
1515
isVSCodeServer,
1616
isVSCodeTerminal,
1717
jupyterHubHttpReferrer,
@@ -58,7 +58,7 @@ export async function printBrowsePreviewMessage(
5858
path: string,
5959
) {
6060
if (
61-
(isJupyterServer() || isVSCodeTerminal()) && isRStudioWorkbench()
61+
(isJupyterServer() || isVSCodeTerminal()) && isPositWorkbench()
6262
) {
6363
const url = await rswURL(port, path);
6464
info(`\nPreview server: ${previewURL(host, port, path = "")}`);

0 commit comments

Comments
 (0)