Skip to content

Fix: Python single-line comments incorrectly highlighting subsequent lines#3

Open
hygjob wants to merge 2 commits into
taf2:masterfrom
hygjob:fix-python-comment-highlight
Open

Fix: Python single-line comments incorrectly highlighting subsequent lines#3
hygjob wants to merge 2 commits into
taf2:masterfrom
hygjob:fix-python-comment-highlight

Conversation

@hygjob

@hygjob hygjob commented Jun 17, 2026

Copy link
Copy Markdown

Bug Description

When rendering fenced Python code blocks, single-line comments starting with # would incorrectly cause the next line to be rendered with comment styling (dim fallback) instead of proper syntax highlighting.

Root Cause

syntect's HighlightLines::highlight_line() requires a trailing newline (\n) to properly terminate line-based scopes such as Python single-line comments. Without it, the comment scope leaks into the next line's highlighting context.

Changes

  • src/renderer.rs: Append a trailing newline to each line before calling highlight_line(), then trim it from the resulting spans. Added a regression test (python_comment_does_not_affect_next_lines) to verify the fix.
  • src/app.rs: Applied a minor clippy suggestion (or_elseor for Option references).

Verification

cargo test python_comment_does_not_affect_next_lines
New test passes, and existing tests continue to pass.

hygjob and others added 2 commits June 17, 2026 23:09
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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.

1 participant