From 2a7b5758bd1022671d5a44b95e3002816800e429 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Thu, 10 Sep 2026 09:26:53 -0600 Subject: [PATCH 1/3] Fix LSP crash on unparseable cell option YAML by handling null lint result --- apps/lsp/src/quarto.ts | 4 ++-- apps/lsp/src/service/providers/diagnostics-yaml.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/lsp/src/quarto.ts b/apps/lsp/src/quarto.ts index e0a33460..6dd5799d 100644 --- a/apps/lsp/src/quarto.ts +++ b/apps/lsp/src/quarto.ts @@ -38,7 +38,7 @@ export interface Quarto extends QuartoContext { token: AttrToken, context: EditorContext ): Promise; - getYamlDiagnostics(context: EditorContext): Promise; + getYamlDiagnostics(context: EditorContext): Promise; getHover?: (context: EditorContext) => Promise; } @@ -168,7 +168,7 @@ function normalizedValue(value: string, simpleDiv: boolean) { interface QuartoYamlModule { getCompletions(context: EditorContext): Promise; - getLint(context: EditorContext): Promise>; + getLint(context: EditorContext): Promise | null>; getHover?: (context: EditorContext) => Promise; } diff --git a/apps/lsp/src/service/providers/diagnostics-yaml.ts b/apps/lsp/src/service/providers/diagnostics-yaml.ts index 46c95cb7..97bf204f 100644 --- a/apps/lsp/src/service/providers/diagnostics-yaml.ts +++ b/apps/lsp/src/service/providers/diagnostics-yaml.ts @@ -26,7 +26,7 @@ export async function provideYamlDiagnostics( ): Promise { const context = docEditorContext(doc, Position.create(0, 0), true); - const diagnostics = await quarto.getYamlDiagnostics(context); + const diagnostics = (await quarto.getYamlDiagnostics(context)) ?? []; return diagnostics.map((item) => { return { severity: lintSeverity(item), From 7c2184e741bde74615cacc143ebe0e23d1a868d8 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Thu, 10 Sep 2026 09:40:47 -0600 Subject: [PATCH 2/3] Update CHANGELOG --- apps/vscode/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index d024fab4..81831fdd 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -4,6 +4,7 @@ - In Positron, running a Python cell in a knitr document now respects the `quarto.cells.useReticulate` setting, instead of always routing it through reticulate on the R console (). - In Positron, when Positron serves language features for code cells itself (the `quarto.embeddedLanguageFeatures.native` setting), the extension no longer serves them from virtual document temp files (). +- Fixed a crash of the Quarto language server on save when a code cell contained unparseable YAML options (e.g. an unquoted `fig-cap` value containing a colon) (). ## 1.137.0 (Release on 2026-09-04) From de07dbfcf8307272c0eeded6fea30549b73819d0 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Fri, 11 Sep 2026 08:14:30 -0600 Subject: [PATCH 3/3] Normalize null YAML lint result to empty array at module boundary --- apps/lsp/src/quarto.ts | 6 ++++-- apps/lsp/src/service/providers/diagnostics-yaml.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/lsp/src/quarto.ts b/apps/lsp/src/quarto.ts index 6dd5799d..2062de3a 100644 --- a/apps/lsp/src/quarto.ts +++ b/apps/lsp/src/quarto.ts @@ -38,7 +38,7 @@ export interface Quarto extends QuartoContext { token: AttrToken, context: EditorContext ): Promise; - getYamlDiagnostics(context: EditorContext): Promise; + getYamlDiagnostics(context: EditorContext): Promise; getHover?: (context: EditorContext) => Promise; } @@ -50,7 +50,9 @@ export async function initializeQuarto(context: QuartoContext): Promise getAttrCompletions: initializeAttrCompletionProvider( context.resourcePath ), - getYamlDiagnostics: quartoModule.getLint, + // the external getLint() resolves to null when linting fails + getYamlDiagnostics: async (context) => + (await quartoModule.getLint(context)) ?? [], getHover: quartoModule.getHover }; diff --git a/apps/lsp/src/service/providers/diagnostics-yaml.ts b/apps/lsp/src/service/providers/diagnostics-yaml.ts index 97bf204f..46c95cb7 100644 --- a/apps/lsp/src/service/providers/diagnostics-yaml.ts +++ b/apps/lsp/src/service/providers/diagnostics-yaml.ts @@ -26,7 +26,7 @@ export async function provideYamlDiagnostics( ): Promise { const context = docEditorContext(doc, Position.create(0, 0), true); - const diagnostics = (await quarto.getYamlDiagnostics(context)) ?? []; + const diagnostics = await quarto.getYamlDiagnostics(context); return diagnostics.map((item) => { return { severity: lintSeverity(item),