Skip to content

Commit

Permalink
Put behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Nov 24, 2024
1 parent ee4b359 commit 01ab77a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions extensions/positron-r/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@
},
"default": [],
"description": "%r.configuration.extraArguments.description%"
},
"positron.r.taskHyperlinks": {
"scope": "window",
"type": "boolean",
"default": false,
"description": "%r.configuration.taskHyperlinks.description%"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion extensions/positron-r/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
"r.configuration.pipe.magrittr.token": "%>%",
"r.configuration.pipe.native.description": "Native pipe available in R >= 4.1",
"r.configuration.pipe.magrittr.description": "Pipe operator from the magrittr package, re-exported by many other packages",
"r.configuration.diagnostics.enable.description": "Enable R diagnostics globally"
"r.configuration.diagnostics.enable.description": "Enable R diagnostics globally",
"r.configuration.taskHyperlinks.description": "Turn on experimental support for hyperlinks in package development tasks"
}
16 changes: 14 additions & 2 deletions extensions/positron-r/src/uri-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ export async function registerUriHandler() {
vscode.window.registerUriHandler({ handleUri });
}

// Temporary feature flag to finesse the fact that cli hyperlinks are either all ON or all OFF.
// cli 3.6.3.9001 gained support for configuring the URL format of run/help/vignette hyperlinks.
// But file hyperlinks are not yet configurable and will delegate to operating system.
// If the user still has RStudio as the app associated with .R files, it will open in RStudio.
// Flag will be removed once cli can be configured to emit positron://file/... hyperlinks.
function taskHyperlinksEnabled(): boolean {
const extConfig = vscode.workspace.getConfiguration('positron.r');
const taskHyperlinksEnabled = extConfig.get<boolean>('taskHyperlinks');

return taskHyperlinksEnabled === true;
}

// Example of a URI we expect to handle:
// positron://positron.positron-r/cli?command=x-r-run:testthat::snapshot_review('snap')
//
Expand Down Expand Up @@ -60,11 +72,11 @@ export async function prepCliEnvVars(session?: RSession): Promise<EnvVar> {
return {};
}

// cli 3.6.3.9001 gained support for configuring the URL format for hyperlinks.
const taskHyperlinks = taskHyperlinksEnabled();
const cliPkg = await session.packageVersion('cli', '3.6.3.9001');
const cliSupportsHyperlinks = cliPkg?.compatible ?? false;

if (!cliSupportsHyperlinks) {
if (!taskHyperlinks || !cliSupportsHyperlinks) {
// eslint-disable-next-line @typescript-eslint/naming-convention
return { R_CLI_HYPERLINKS: 'FALSE' };
}
Expand Down

0 comments on commit 01ab77a

Please sign in to comment.