Skip to content

quarto create should not automatically open new positron window when inside workbench #12965

Open
@cderv

Description

@cderv

Shared by @MariaSemple and @jthomasmock on Slack

quarto create does try to be clever by detecting editors, and opening the new created project inside the same editor in a new window

This is a problem inside Posit Workbench where Positron can be opened. And from @jthomasmock

On Workbench, inside a Positron terminal, $ quarto create with a new project will create the files and then relaunch the Positron session into that folder without prompting the user.

and from @MariaSemple

the behaviour in Workbench feels unexpected for a user and could lead to some undesirable circumstances we're trying to avoid

Supported editors

export const kEditorInfos: EditorInfo[] = [
positronEditorInfo(),
vscodeEditorInfo(),
rstudioEditorInfo(),
];

Each editor defines a open function like

function positronEditorInfo(): EditorInfo {
const editorInfo: EditorInfo = {
id: "positron",
name: "positron",
open: (path: string, createResult: CreateResult) => {
const artifactPath = createResult.path;
const cwd = Deno.statSync(artifactPath).isDirectory
? artifactPath
: dirname(artifactPath);
return async () => {
await call(path, { args: [artifactPath], cwd });
};
},
inEditor: isPositronTerminal(),
actions: [],
};

and quarto tries to check for editor and if detected, use the open function

// Now that the article was created, offer to open the item
if (allowPrompt && options.open !== false) {
const resolvedEditor = await resolveEditor(
createResult,
typeof (options.open) === "string" ? options.open : undefined,
);
if (resolvedEditor) {
resolvedEditor.open();
}
}

// See if we are executing inside of an editor, and just use
// that editor
const inEditor = editors.find((ed) => ed.inEditor);
if (inEditor) {
return inEditor;

So we need to detect and make an exception inside workbench that we can already detect

export function isRStudioWorkbench() {
// RS_SERVER_URL e.g. https://daily-rsw.soleng.rstudioservices.com/
// RS_SESSION_URL e.g. /s/eae053c9ab5a71168ee19/
return !!Deno.env.get("RS_SERVER_URL") && !!Deno.env.get("RS_SESSION_URL");
}

Metadata

Metadata

Assignees

Labels

editorsIssues with editing in text editors, IDEs, etcenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions