Fix stale diagnostics in Ruff playground (#17583)

This commit is contained in:
Micha Reiser 2025-04-23 15:47:54 +02:00 committed by GitHub
parent 8abf93f5fb
commit 624f5c6c22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 19 deletions

View File

@ -41,10 +41,10 @@
"pyodide": "^0.27.4",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-resizable-panels": "^2.1.8",
"react-resizable-panels": "^2.1.7",
"red_knot_wasm": "file:red_knot_wasm",
"shared": "0.0.0",
"smol-toml": "^1.3.3"
"smol-toml": "^1.3.1"
},
"devDependencies": {
"vite-plugin-static-copy": "^2.3.0"
@ -6087,14 +6087,14 @@
"monaco-editor": "^0.52.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-resizable-panels": "^2.1.8",
"react-resizable-panels": "^2.0.0",
"ruff_wasm": "file:ruff_wasm",
"shared": "0.0.0",
"smol-toml": "^1.3.3"
"smol-toml": "^1.3.0"
}
},
"ruff/ruff_wasm": {
"version": "0.11.3",
"version": "0.11.4",
"license": "MIT"
},
"shared": {
@ -6103,7 +6103,7 @@
"@monaco-editor/react": "^4.7.0",
"classnames": "^2.3.2",
"react": "^19.0.0",
"react-resizable-panels": "^2.1.8"
"react-resizable-panels": "^2.1.7"
}
}
}

View File

@ -66,27 +66,28 @@ function Items({
);
}
const uniqueIds: Map<string, number> = new Map();
return (
<ul className="space-y-0.5 grow overflow-y-scroll">
{diagnostics.map((diagnostic, index) => {
{diagnostics.map((diagnostic) => {
const row = diagnostic.start_location.row;
const column = diagnostic.start_location.column;
const mostlyUniqueId = `${row}:${column}-${diagnostic.code}`;
const disambiguator = uniqueIds.get(mostlyUniqueId) ?? 0;
uniqueIds.set(mostlyUniqueId, disambiguator + 1);
return (
<li
key={`${diagnostic.start_location.row}:${diagnostic.start_location.column}-${diagnostic.code ?? index}`}
>
<li key={`${mostlyUniqueId}-${disambiguator}`}>
<button
onClick={() =>
onGoTo(
diagnostic.start_location.row,
diagnostic.start_location.column,
)
}
onClick={() => onGoTo(row, column)}
className="w-full text-start cursor-pointer select-text"
>
{diagnostic.message}{" "}
<span className="text-gray-500">
{diagnostic.code != null && `(${diagnostic.code})`} [Ln{" "}
{diagnostic.start_location.row}, Col{" "}
{diagnostic.start_location.column}]
{diagnostic.code != null && `(${diagnostic.code})`} [Ln {row},
Col {column}]
</span>
</button>
</li>