Bug Report: R Language Server emits spurious `comment` semantic tokens for first character of every line in `.qmd` files
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Riproduci il problema in VS Code o Cursor usando l’esempio .qmd fornito e ispeziona i token semantici con Developer: Inspect Editor Tokens and Scopes. Traccia l’emissione dei token di commento nel R Language Server o nel bridge LSP dell’estensione Quarto, concentrandoti sugli intervalli dei blocchi di codice R. Il lavoro è completato quando i token di commento rimangono sui commenti R effettivi senza colorare contenuti YAML, markdown, intestazioni o contenuti matematici.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When a .qmd file contains one or more R code chunks, the R Language Server (or Quarto VS Code extension) emits a comment semantic token covering the first character of every line in the document — including YAML front matter keys, markdown prose, headings, and LaTeX math delimiters. This colors all those first characters green (#008000), overriding the correct TextMate grammar colors.
Environment
- Editor: Cursor (VS Code-based)
- Quarto extension: quarto.quarto (version: 1.133.0)
- R languageserver: 0.3.18
- OS: Windows 11
Steps to Reproduce
- Create a
.qmdfile with a standard YAML front matter and at least one R code chunk, e.g.:
---
title: "Test"
bibliography: refs.bib
format:
html:
toc: true
---
# Section heading
This is a paragraph of text.
$$
x = y + z
$$ {#eq-test}
```{r}
#| echo: false
print("hello")
```
- Open the file in VS Code / Cursor with the Quarto extension installed and an R Language Server active.
- Observe that the first character of every line (the
tintitle, the#in# Section heading, theTinThis is a paragraph, the$of$$, etc.) is colored green. - Use Developer: Inspect Editor Tokens and Scopes (Ctrl+Shift+P) with the cursor on any affected first character.
Observed Token Info (from Inspect Editor Tokens and Scopes)
Example: first character t of YAML key title:
language yaml
standard token String
foreground #008000
semantic token comment
foreground comment → { "foreground": "#008000" }
textmate scopes entity.name.tag.yaml
string.unquoted.plain.out.yaml
meta.embedded.block.frontmatter
text.html.quarto
foreground meta.embedded.block.frontmatter entity.name.tag.yaml → { "foreground": "#800000" }
Example: first $ of a display math block $$:
language quarto
standard token Other
foreground #008000
semantic token comment
foreground comment → { "foreground": "#008000" }
textmate scopes keyword.control.import.math.begin.quarto
markup.math.block.quarto
text.html.quarto
foreground keyword.control → { "foreground": "#0000FF" }
The semantic comment token (green, #008000) overrides the correct TextMate colors for every affected character.
Expected Behaviour
The comment semantic token should only be emitted for actual R comments (lines beginning with # inside R code chunks). It should not be applied to:
- YAML front matter keys
- Markdown prose
- Heading markers
- LaTeX math delimiters (
$,$$) - Any other non-R content
Actual Behaviour
The comment semantic token is applied to the first character of every line in the document whenever at least one R code chunk is present.
Key Observations
- The issue is absent when the
.qmdfile contains no R code chunks. - Removing all R code chunks from an affected file immediately resolves the green coloring.
- A
.qmdfile with identical front matter and body but no R chunks shows no issue. - The issue is therefore triggered by R Language Server activation, not by the YAML or Quarto language servers alone.
- This behaviour was not present in earlier versions; it appears to be a recent regression.
Workaround
Add the following to .vscode/settings.json in the workspace to suppress the spurious color while preserving correct R comment coloring:
{
"editor.semanticTokenColorCustomizations": {
"rules": {
"comment:yaml": "#800000",
"comment:quarto": "#000000",
"comment:r": "#008000"
}
}
}
Suggested Fix
The R Language Server (or the Quarto extension's LSP bridge) should scope semantic token emission to the language region of each token — i.e., comment tokens should only be emitted within R code block ranges, not propagated to the surrounding markdown/YAML document.
- Lingua principale
- R
- Stelle
- 675
- Fork
- 118
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di REditorSupport/languageserver
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
REditorSupport/languageserver#776 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
REditorSupport/languageserver#731 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
REditorSupport/languageserver#730 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
REditorSupport/languageserver#771 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
REditorSupport/languageserver#772 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di REditorSupport/languageserver
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
futureverse/future#838 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
api-sync
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sportsdataverse/hoopR#220 ·
-
Honest R dependency policyApertacompat
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mlr-org/batchtools#332 · 3 commenti ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
Open-Systems-Pharmacology/OSPSuite.ParameterIdentification#315 ·