Skip to content

Commit 624f5c6

Browse files
authored
Fix stale diagnostics in Ruff playground (#17583)
1 parent 8abf93f commit 624f5c6

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

playground/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/ruff/src/Editor/Diagnostics.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,28 @@ function Items({
6666
);
6767
}
6868

69+
const uniqueIds: Map<string, number> = new Map();
70+
6971
return (
7072
<ul className="space-y-0.5 grow overflow-y-scroll">
71-
{diagnostics.map((diagnostic, index) => {
73+
{diagnostics.map((diagnostic) => {
74+
const row = diagnostic.start_location.row;
75+
const column = diagnostic.start_location.column;
76+
const mostlyUniqueId = `${row}:${column}-${diagnostic.code}`;
77+
78+
const disambiguator = uniqueIds.get(mostlyUniqueId) ?? 0;
79+
uniqueIds.set(mostlyUniqueId, disambiguator + 1);
80+
7281
return (
73-
<li
74-
key={`${diagnostic.start_location.row}:${diagnostic.start_location.column}-${diagnostic.code ?? index}`}
75-
>
82+
<li key={`${mostlyUniqueId}-${disambiguator}`}>
7683
<button
77-
onClick={() =>
78-
onGoTo(
79-
diagnostic.start_location.row,
80-
diagnostic.start_location.column,
81-
)
82-
}
84+
onClick={() => onGoTo(row, column)}
8385
className="w-full text-start cursor-pointer select-text"
8486
>
8587
{diagnostic.message}{" "}
8688
<span className="text-gray-500">
87-
{diagnostic.code != null && `(${diagnostic.code})`} [Ln{" "}
88-
{diagnostic.start_location.row}, Col{" "}
89-
{diagnostic.start_location.column}]
89+
{diagnostic.code != null && `(${diagnostic.code})`} [Ln {row},
90+
Col {column}]
9091
</span>
9192
</button>
9293
</li>

0 commit comments

Comments
 (0)