Bug Report: R Language Server emits spurious `comment` semantic tokens for first character of every line in `.qmd` files
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
提供された .qmd の例を使用して VS Code または Cursor で問題を再現し、Developer: Inspect Editor Tokens and Scopes でセマンティックトークンを調べます。R Language Server または Quarto 拡張機能の LSP ブリッジにおけるコメントトークンの発行を追跡し、R コードチャンクの範囲に注目します。完了条件は、YAML、markdown、見出し、数式の内容に色が付かず、実際の R コメント上にコメントトークンが残ることです。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- R
- スター
- 678
- フォーク
- 118
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 10
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
REditorSupport/languageserver のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
REditorSupport/languageserver#780 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
REditorSupport/languageserver#776 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
REditorSupport/languageserver#731 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
REditorSupport/languageserver#730 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
REditorSupport/languageserver#771 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
REditorSupport/languageserver の issue をすべて見る
似ている issue
-
core
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
insightsengineering/teal#1747 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
JamesHWade/deputy#236 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 3 日以内に返信
-
Elevation orderオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
inbo/erl-butterflies-2025#19 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100