Skip to content

Enable Render on Save toggle in visual editor - #1121

Open
juliasilge wants to merge 2 commits into
mainfrom
render-on-save-visual-editor
Open

Enable Render on Save toggle in visual editor#1121
juliasilge wants to merge 2 commits into
mainfrom
render-on-save-visual-editor

Conversation

@juliasilge

Copy link
Copy Markdown
Collaborator

The Render on Save checkbox appears in the visual editor's action bar, but it wasn't correctly working there. This PR makes the checkbox (more) correctly functional in the visual editor. I'll be honest that there is still some weirdness with the quarto.render.renderOnSave setting, but this is an improvement.

This is the Quarto-side follow-up called out in posit-dev/positron#16022, which is making extension-contributed action bar checkboxes follow their command's enablement expression. cc @dhruvisompura

Root cause

Two issues:

  1. The quarto.toggleRenderOnSave command's enablement was editorLangId == quarto, which doesn't match when the visual editor (a custom editor) is active so the checkbox was not fully/correctly enabled there.
  2. The quarto.editor.type / quarto.editor.renderOnSave / quarto.editor.renderOnSaveShiny context keys that drive the checkbox's checked state were only updated via onDidChangeActiveTextEditor, which custom editors don't fire, so the state was stale even where the checkbox was visible.

Changes

  • package.json: add activeCustomEditorId == 'quarto.visualEditor' to the command's enablement, matching the pattern used by other menu contributions.
  • editor.ts: add an onDidChangeActiveEditor event to the visual editor tracker, fired from each tracked webview panel's onDidChangeViewState when its panel becomes active, and expose it via VisualEditorProvider.onDidChangeActiveEditor().
  • context-keys.ts: refactor setEditorContextKeys / setLanguageContextKeys to take a TextDocument (they only ever used the document), subscribe to the new event so context keys refresh when a visual editor gains focus, and fall back to the active visual editor's document in the configuration-change listener.

Validation

  • Open a .qmd in visual mode: the checkbox appears and is clickable.
  • Toggle the checkbox in visual mode and save: render kicks off when checked, doesn't when unchecked.
  • Toggle in visual mode, switch to source mode (and back): state carries across.
  • Regression: source-mode behavior unchanged; checkbox stays hidden for non-Quarto files.

@posit-snyk-bot

posit-snyk-bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants