Skip to content

Run cells of any language with a Positron runtime - #1237

Open
michaelmayer2 wants to merge 3 commits into
quarto-dev:mainfrom
michaelmayer2:positron-runtime-cells
Open

michaelmayer2 wants to merge 3 commits into
quarto-dev:mainfrom
michaelmayer2:positron-runtime-cells

Conversation

@michaelmayer2

@michaelmayer2 michaelmayer2 commented Nov 19, 2026 •

Copy link
Copy Markdown

Problem

In Positron with inline output off, Quarto runs cells only for julia, python, csharp and r, the hard-coded cases in cellExecutorForLanguage in src/host/positron.ts. Other languages fall back to the static executor list. So cells for runtimes that extensions add, such as {ggsql} (ggsql extension) or {sas} (SAS extension, common through the sasquatch R package), get no Run Cell lens. quarto.runCurrentCell and the other run commands do nothing on them. With inline output on, Positron decides instead, from the languageRuntimes contributions (hasLanguageRuntimeProvider), so the two modes disagree.

Change

  • Languages with a Positron runtime (positron.ts) come from two sources, as in hasLanguageRuntimeProvider:

    1. The languageRuntimes contributions in the package.json of the installed extensions (vscode.extensions.all), re-read on vscode.extensions.onDidChange. This read is synchronous and known before those extensions activate or discover a runtime. The parsing is the pure contributedRuntimeLanguages().
    2. The registered runtimes (getRegisteredRuntimes() and onDidRegisterRuntime), for an extension that registers a runtime without the contribution.

    Both are cached because hasExecutor() is synchronous. They are filled only in Positron, so VS Code is unaffected even with such extensions installed.

  • The existing Positron executor moves unchanged into positronRuntimeExecutor(). The built-in languages use it as before, and in the default: branch any language with a Positron runtime uses it too. hasExecutor() and the host's executableLanguages include these languages, so lenses, Run Above / Run Next Cell and the shortcuts work for them.

  • Option lines: codeWithoutOptionsFromBlock also strips the leading option lines of languages with a Positron runtime, using each language's comment characters from kLangCommentChars:

    • ggsql has no entry there, so its options are #|, and its docs use #| too. But # isn't a comment in ggsql (--, // and /* */ are), so those lines used to reach the console as code.
    • SAS uses *| …;.

    The matching is the one cellOptions() uses, now shared as leadingOptionYaml(). Languages without a runtime behave as before.

Positron's longer-term fix is tracked in posit-dev/positron#17432.

Testing

  • tsc --noEmit and eslint pass.
  • VS Code suite: 6 new tests cover the option stripping (sas, ggsql, no runtime, option-like lines after code) and the manifest parsing. All 9 tests in cellExecutors.test.ts pass. In the full main suite, the only failures are 4 Convert .qmd → .ipynb tests, which also fail on this branch's base on my machine.
  • Manual test in Positron 2026.12 (VS Code 1.143). I used a separate profile with a VSIX of this branch, the SAS extension with its languageRuntimes contribution (Positron: declare the SAS language runtime in the manifest posit-dev/positron-sas-extension#167), and ggsql 0.5.2:
    • Inline output off:
      • {ggsql} and {sas} cells show lenses before any console exists.
      • Cmd+Shift+Enter, Cmd+Enter, Run Next Cell and Run Above run in the right console.
      • The option lines are not sent, and ggsql raises no parse error.
    • Inline output on: both languages run.

🤖 Generated with Claude Code

michaelmayer2 and others added 2 commits November 19, 2026 09:44
In Positron, only R, Python, Julia and C# cells ran in the console.
Cells for runtimes that other extensions register, such as {sas} from
the SAS extension, got no Run Cell lens, and the run commands did
nothing on them.

Track the languages of registered Positron runtimes and treat them as
executable, running their cells with the same executor as the built-in
languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@posit-snyk-bot

posit-snyk-bot commented Nov 19, 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.

@juliasilge juliasilge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR and for the detailed write-up! We're excited to get SAS working well in Positron. 🙌

When inline output is off, the Quarto extension does decide which cells can run, so we do need a change here in this extension. We actually have the same problem for {ggsql} cells as well. For example, with inline output off, Cmd+Enter and the code lenses do nothing for either a ggsql or SAS document.

This PR is not quite the right approach yet for Quarto support, though. Right now, this fills the list from getRegisteredRuntimes() and onDidRegisterRuntime, but a runtime registers only after its extension activates and discovers an interpreter or a profile. For SAS, this occurs only after a connection profile exists. Before that, {sas} cells get no lenses, and the lenses come back only on the next lens refresh. When inline output is on, Positron uses a different source to decide this, the languageRuntimes contribution in the package.json of each extension (hasLanguageRuntimeProvider in runtimeStartup.ts). As a result, the two modes can disagree.

A better approach is to change the source of the language list, so that both modes agree on which cells can run:

  1. Read the languageRuntimes contributions in the Quarto extension. Collect packageJSON.contributes.languageRuntimes[].languageId from vscode.extensions.all, and refresh the list on vscode.extensions.onDidChange. This is synchronous, it is available before other extensions activate, and it matches the source that Positron uses for inline output.
  2. Keep the registered runtimes from this PR as a second source, and use the union of the two lists. This covers an extension that registers a runtime but has no manifest entry.
  3. Test in a Positron dev build with inline output off, with {ggsql} and {sas} cells. Test the lenses, Run Above, Run Next Cell, and Cmd+Enter.

I logged posit-dev/positron#17432 for us to improve this situation, but this PR doesn't need to wait for that.

For SAS, the SAS extension needs to also add this contribution to its package.json (ggsql already does this):

"contributes": {
  "languageRuntimes": [{ "languageId": "sas" }]
}

After a Quarto extension release includes this PR, the SAS extension will need to hide the {sas} lenses from posit-dev/positron-sas-extension#163 for that Quarto version. If it doesn't, each {sas} cell will show two Run Cell lenses.

One more item to think through is that right now codeWithoutOptionsFromBlock removes option lines only for languages that use #|. Please make sure that the option lines in {ggsql} cells do not cause errors when they go to the console.

Use the `languageRuntimes` contributions in the extensions' package.json
as the main source of languages whose cells run in a Positron console,
as Positron does for inline output (`hasLanguageRuntimeProvider`), and
keep the registered runtimes as a second source. The contributions are
known before the extensions activate or discover a runtime, so e.g.
`{sas}` cells are runnable before a SAS connection profile exists, and
both modes agree on which cells can run.

Strip the leading option lines of these languages before sending the
code to the console, using each language's own comment characters
(`#|` for ggsql, where `#` isn't a comment, and `*| ...;` for sas). The
matching is shared with cellOptions().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michaelmayer2

Copy link
Copy Markdown
Author

Thanks for the careful review! I've reworked the PR along those lines (c75a7a4):

  1. Manifest as the main source. positron.ts now reads contributes.languageRuntimes[].languageId from vscode.extensions.all and re-reads it on vscode.extensions.onDidChange. The read is synchronous, so the languages are known when Quarto activates, before other extensions activate or discover anything. The parsing is a pure function, contributedRuntimeLanguages(), with unit tests.
  2. Union with registered runtimes. The getRegisteredRuntimes() / onDidRegisterRuntime set stays as a second source. hasPositronRuntime() checks both, which mirrors hasLanguageRuntimeProvider. Both sets are filled only in Positron, so VS Code is unaffected even with such extensions installed.
  3. Tested in Positron. I tested in Positron 2026.12, in a separate profile, with a VSIX of this branch, ggsql 0.5.2 and the SAS extension with its new manifest entry:
    • With inline output off, {ggsql} and {sas} cells show lenses before any console exists. Cmd+Shift+Enter, Cmd+Enter, Run Next Cell and Run Above run in the right console.
    • With inline output on, both languages run too.
  4. SAS extension. It now declares "languageRuntimes": [{ "languageId": "sas" }] in Positron: declare the SAS language runtime in the manifest posit-dev/positron-sas-extension#167. Once a Quarto release includes this PR, its own {sas} lenses will step aside for that version.
  5. ggsql option lines. Good catch. The ggsql docs write cell options as #|, since ggsql has no entry in kLangCommentChars and falls back to #, but # isn't a comment in ggsql (--, // and /* */ are). codeWithoutOptionsFromBlock now strips the leading option lines of any language with a Positron runtime, using that language's comment characters: #| for ggsql, *| …; for SAS. It uses the same matching as cellOptions(), now shared as leadingOptionYaml(). In the manual test, ggsql cells with #| label / #| error lines run without a parse error. Languages without a runtime behave as before, including the existing stata test.

Thanks for logging posit-dev/positron#17432!

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.

3 participants