-
Notifications
You must be signed in to change notification settings - Fork 971
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
LSP diagnostics (such as Ruff's "Undefined name") are not cleared and remain visible in the cell editor even after the code is fixed (e.g., changing a to a = 1).
This has been observed on Windows (Native, WSL2, devcontainer). I am not sure if this issue persists on other platforms.
1. Enter a (Error appears) |
2. Change to a = 1 (Error remains) |
|---|---|
![]() |
![]() |
I experimented with the code in frontend/src/core/codemirror/lsp/notebook-lsp.ts and found that the publishDiagnostics notification for clearing errors was missing the version field.
After I manually added the version field to the "clear" loop in the patchProcessNotification method, the diagnostics started clearing correctly.
However, I am not certain if this is the correct way to fix the issue.
(Update: This fix also resolved persistent diagnostics in basedpyright.)
// frontend/src/core/codemirror/lsp/notebook-lsp.ts
// ... inside patchProcessNotification's clear loop
for (const cellDocumentUri of cellsToClear) {
previousProcessNotification({
method: "textDocument/publishDiagnostics",
params: {
uri: cellDocumentUri,
version: cellVersion, // <--- Adding this line fixed the issue
diagnostics: [],
},
});
}Will you submit a PR?
- Yes
Environment
Details
{
"marimo": "0.20.4",
"editable": true,
"location": "/workspaces/marimo/marimo",
"OS": "Linux",
"OS Version": "6.6.87.2-microsoft-standard-WSL2",
"Processor": "x86_64",
"Python Version": "3.12.13",
"Locale": "--",
"Binaries": {
"Browser": "--",
"Node": "v22.22.0",
"uv": "0.6.17"
},
"Dependencies": {
"click": "8.3.1",
"docutils": "0.22.4",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.10.2",
"narwhals": "2.17.0",
"packaging": "26.0",
"psutil": "7.2.2",
"pygments": "2.19.2",
"pymdown-extensions": "10.21",
"pyyaml": "6.0.3",
"starlette": "0.52.1",
"tomlkit": "0.14.0",
"typing-extensions": "4.15.0",
"uvicorn": "0.41.0",
"websockets": "16.0"
},
"Optional Dependencies": {
"basedpyright": "1.38.2",
"duckdb": "1.4.4",
"loro": "1.10.3",
"openai": "2.26.0",
"pyarrow": "23.0.1",
"pytest": "9.0.2",
"python-lsp-ruff": "2.3.0",
"python-lsp-server": "1.14.0",
"ruff": "0.15.1",
"sqlglot": "29.0.1"
},
"Experimental Flags": {
"multi_column": true,
"cache_panel": true
}
}
Code to reproduce
- Create a new notebook.
- In a cell, type
a. - Wait for the LSP (Ruff) to show an error:
Undefined name 'a'. - Change the code to
a = 1. - Observed Behavior: The red underline and error message for
Undefined name 'a'remain in the editor. - Expected Behavior: The error should disappear immediately after the code becomes valid.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

