diff --git a/extensions/positron-r/package.json b/extensions/positron-r/package.json index 7941b5b405b..82eb3c1d68a 100644 --- a/extensions/positron-r/package.json +++ b/extensions/positron-r/package.json @@ -281,6 +281,12 @@ }, "default": [], "description": "%r.configuration.extraArguments.description%" + }, + "positron.r.taskHyperlinks": { + "scope": "window", + "type": "boolean", + "default": false, + "description": "%r.configuration.taskHyperlinks.description%" } } } diff --git a/extensions/positron-r/package.nls.json b/extensions/positron-r/package.nls.json index 3f5ee6eb8ab..6a12749ba20 100644 --- a/extensions/positron-r/package.nls.json +++ b/extensions/positron-r/package.nls.json @@ -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" } diff --git a/extensions/positron-r/src/uri-handler.ts b/extensions/positron-r/src/uri-handler.ts index 4cd893b69ed..3e85cb0c296 100644 --- a/extensions/positron-r/src/uri-handler.ts +++ b/extensions/positron-r/src/uri-handler.ts @@ -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('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') // @@ -60,11 +72,11 @@ export async function prepCliEnvVars(session?: RSession): Promise { 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' }; }