Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
"editor/title/run": [
{
"command": "quarto.preview",
"when": "editorLangId == quarto || editorLangId == markdown || activeCustomEditorId == 'quarto.visualEditor'"
"when": "(editorLangId == quarto || editorLangId == markdown || activeCustomEditorId == 'quarto.visualEditor') && !quartoCanUsePositronPreviewSplitButton"
},
{
"command": "quarto.previewScript",
Expand Down
26 changes: 26 additions & 0 deletions apps/vscode/src/providers/context-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import * as vscode from "vscode";
import debounce from "lodash.debounce";
import { tryAcquirePositronApi } from "@posit-dev/positron";

import { isQuartoDoc } from "../core/doc";
import { MarkdownEngine } from "../markdown/engine";
Expand Down Expand Up @@ -44,6 +45,9 @@ export function activateContextKeySetter(
setEditorContextKeys(vscode.window.activeTextEditor, engine);
setLanguageContextKeys(vscode.window.activeTextEditor, engine);

// set the Positron preview split-button context key (static for the session)
setPositronPreviewSplitButtonContextKey();

// register for quarto.render.renderOnSave or quarto.render.renderOnSaveShiny configuration change notification
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(event => {
// if the change affects quarto.render.renderOnSave or quarto.render.renderOnSaveShiny, set the editor context keys.
Expand Down Expand Up @@ -118,6 +122,28 @@ export function toggleRenderOnSaveOverride() {
}
}

// Positron 2026.07.0+ provides a native Preview split button on the editor
// action bar, with per-format preview in its dropdown. When running in such a
// Positron, this context key lets us hide the extension's own `editor/title/run`
// Preview button so there is a single button. Gating on the version (rather than
// a Positron-set feature flag) keeps this temporal logic in the extension; the
// check and key can be deleted once the supported Positron floor reaches that
// version.
//
// String comparison, not `semver`: calendar versions like "2026.07.0" aren't
// valid semver (leading zero in the month), but the zero-padded year/month sort
// correctly lexicographically. This mirrors src/host/positron.ts.
function setPositronPreviewSplitButtonContextKey() {
const positronVersion = tryAcquirePositronApi()?.version;
const canUsePositronPreviewSplitButton =
positronVersion !== undefined && positronVersion >= "2026.07.0";
vscode.commands.executeCommand(
"setContext",
"quartoCanUsePositronPreviewSplitButton",
canUsePositronPreviewSplitButton
);
}

// sets editor context keys
function setEditorContextKeys(activeTextEditor: vscode.TextEditor | undefined, engine: MarkdownEngine) {
// if a Quarto doc is active, set the editor context keys
Expand Down
Loading