Skip to content

Fix stale diagnostics in Ruff playground #17583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions playground/ruff/src/Editor/Diagnostics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading