From 957b57448c2e505910066b81906bcb3886d73cd5 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 7 Jul 2026 17:48:49 -0600 Subject: [PATCH] Update to handle both new and deprecated Positron setting for inline output --- apps/vscode/src/host/positron.ts | 50 ++++++++++++++++++++++++++++++-- apps/vscode/src/main.ts | 7 +++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/apps/vscode/src/host/positron.ts b/apps/vscode/src/host/positron.ts index 10499a90..03f7f4e8 100644 --- a/apps/vscode/src/host/positron.ts +++ b/apps/vscode/src/host/positron.ts @@ -27,14 +27,58 @@ import { Position, Range } from 'vscode'; import { Uri } from 'vscode'; import { tryAcquirePositronApi } from '@posit-dev/positron'; +/** + * The canonical Positron setting for enabling Quarto inline output. + */ +export const kInlineOutputEnabledSetting = "quarto.inlineOutput.enabled"; + +/** + * The deprecated alias for {@link kInlineOutputEnabledSetting}. Positron keeps + * this key working during the deprecation window; reads prefer the new key and + * fall back to this one. + */ +export const kInlineOutputEnabledSettingDeprecated = + "positron.quarto.inlineOutput.enabled"; + /** * Check if inline output is enabled in Positron settings. * This helper is shared with main.ts for code lens visibility. + * + * Prefers the canonical `quarto.inlineOutput.enabled` key and falls back to the + * deprecated `positron.quarto.inlineOutput.enabled` alias when the new key has + * not been explicitly set. Uses `inspect` so an explicit `false` on either key + * is honored over the default. */ export function isInlineOutputEnabled(): boolean { - return vscode.workspace - .getConfiguration("positron.quarto.inlineOutput") - .get("enabled", false); + const config = vscode.workspace.getConfiguration(); + + const inspection = config.inspect(kInlineOutputEnabledSetting); + if (isConfigurationSet(inspection)) { + return config.get(kInlineOutputEnabledSetting, false); + } + + const deprecatedInspection = config.inspect( + kInlineOutputEnabledSettingDeprecated + ); + if (isConfigurationSet(deprecatedInspection)) { + return config.get(kInlineOutputEnabledSettingDeprecated, false); + } + + return false; +} + +/** + * Whether a configuration value has been explicitly set at any level (as + * opposed to falling back to its registered default). + */ +function isConfigurationSet( + inspection: { globalValue?: T; workspaceValue?: T; workspaceFolderValue?: T; } | undefined +): boolean { + return ( + inspection?.globalValue !== undefined || + inspection?.workspaceValue !== undefined || + inspection?.workspaceFolderValue !== undefined + ); } export function positronExtensionHost(outputChannel?: vscode.LogOutputChannel): ExtensionHost { diff --git a/apps/vscode/src/main.ts b/apps/vscode/src/main.ts index 212bef63..a1c04650 100644 --- a/apps/vscode/src/main.ts +++ b/apps/vscode/src/main.ts @@ -34,7 +34,7 @@ import { activateEditor } from "./providers/editor/editor"; import { activateCopyFiles } from "./providers/copyfiles"; import { activateZotero } from "./providers/zotero/zotero"; import { extensionHost } from "./host"; -import { isInlineOutputEnabled } from "./host/positron"; +import { isInlineOutputEnabled, kInlineOutputEnabledSetting, kInlineOutputEnabledSettingDeprecated } from "./host/positron"; import { initQuartoContext, getSourceDescription } from "quarto-core"; import { configuredQuartoPath } from "./core/quarto"; import { activateDenoConfig } from "./providers/deno-config"; @@ -206,7 +206,10 @@ export async function activate(context: vscode.ExtensionContext): Promise { - if (e.affectsConfiguration("positron.quarto.inlineOutput.enabled")) { + if ( + e.affectsConfiguration(kInlineOutputEnabledSetting) || + e.affectsConfiguration(kInlineOutputEnabledSettingDeprecated) + ) { updateCodeLens(); } })