ruff
66355a61 - [red-knot] Fix playground crashes when diagnostics are stale (#17165)

Commit
176 days ago
[red-knot] Fix playground crashes when diagnostics are stale (#17165) ## Summary Fixes a crash in the playground where it crashed with an "index out of bounds" error in the `Diagnostic::to_range` call after deleting content at the end of the file. The root cause was that the playground uses `useDeferred` to avoid too frequent `checkFile` calls (to get a smoother UX). However, this has the problem that the rendered `diagnostics` can be stable (from before the last change). Rendering the diagnostics can then fail because the `toRange` call queries the latest content and not the content from when the diagnostics were created. The fix is "easy" in the sense that we now eagerly perform the `toRange` calls. This way, it doesn't matter when the diagnostics are stale for a few ms. This problem can only be observed on examples where Red Knot is "slow" (takes more than ~16ms to check) because only then does `useDeferred` "debounce" the `check` calls.
Author
Parents
Loading