Skip to content

Ruff errors incorrectly reported on unsaved Markdown files #1000

@OmeGak

Description

@OmeGak

Ruff produces Python linting diagnostics on untitled (unsaved) tabs whose language is set to Markdown. Any text content triggers errors since Ruff parses the entire document as Python source code. This appears to be a regression introduced by #950, which added onLanguage:markdown to the activation events.

Steps to reproduce

  1. Open a new untitled tab (Cmd+N)
  2. Set the language mode to Markdown (via the language selector in the status bar)
  3. Type any plain text, e.g. hello
  4. Observe Python diagnostics reported on line 1 (e.g. F821 Undefined name 'hello', syntax errors, etc.)

Expected behavior

No diagnostics. The file is a Markdown document, not a Python file. Ruff correctly handles saved .md files (only linting inside ```python fences) and the same should apply to unsaved Markdown tabs.

Actual behavior

Ruff parses the entire document as Python source and reports errors on arbitrary prose content.

Root cause hypothesis

For untitled: URIs there is no file extension to infer the language from. Ruff's native server appears to fall back to treating the document as Python rather than reading the languageId (markdown) from the LSP textDocument/didOpen notification. Saved .md files work correctly because the .md extension provides a reliable signal.

Environment

  • Extension version: 2026.38.0
  • Ruff version: v0.15.7 (bundled)
  • VS Code version: 1.115.0
  • OS: macOS

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions