Skip to content

Playground: Fix errors not shown on page load#13262

Merged
MichaReiser merged 1 commit intomainfrom
micha/playground-show-errors-on-load
Sep 9, 2024
Merged

Playground: Fix errors not shown on page load#13262
MichaReiser merged 1 commit intomainfrom
micha/playground-show-errors-on-load

Conversation

@MichaReiser
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser commented Sep 6, 2024

Summary

This PR fixes a bug in the playground where errors for a restored snipped didn't show on page load.

The core issue was that editor or editor.getModels was None when the diagnostics are updated, in which case the useEffect skips the diagnostics change.

This PR fixes the issue by:

  • Using onMount instead of beforeMount to only set the editor instance when the editor is fully loaded
  • Setting the diagnostics as part of the handleMount callback because the mount event could be triggered after are updated

I used this as a chance to only register a single code action provider.

Fixes #11918

Test Plan

Screencast.from.2024-09-06.10-00-24.webm

@MichaReiser MichaReiser added bug Something isn't working playground A playground-specific issue labels Sep 6, 2024
@MichaReiser MichaReiser merged commit 955dc88 into main Sep 9, 2024
@MichaReiser MichaReiser deleted the micha/playground-show-errors-on-load branch September 9, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working playground A playground-specific issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playground does not underline issues on first open until first code change

1 participant