Skip to content

Conversation

trueadm
Copy link
Collaborator

@trueadm trueadm commented Oct 18, 2024

Fixes #439 and fixes #449

Copy link

vercel bot commented Oct 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
omnisite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2024 4:57pm

@trueadm trueadm changed the title fix editor init fix editor selection on file change Oct 18, 2024
@Rich-Harris
Copy link
Member

Still broken for me. Open the playground, add a new file, immediately rename it to foo.js, try and type into the editor, nothing happens. Select App.svelte, try typing, content disappears. Switch back to foo.js, you can now type

@trueadm
Copy link
Collaborator Author

trueadm commented Oct 18, 2024

@Rich-Harris Made some more tweaks and fixes. Now the AST view correctly shows up when renaming files too!

@Rich-Harris
Copy link
Member

This works but the code makes me nervous. We shouldn't be selecting state inside a loop inupdate_files, it should be happening in response to a selection. It feels like this could easily do the wrong thing in some circumstances (e.g. in the tutorial). And we shouldn't need to invalid the entire workspace when we stop editing a filename.

I think there are some deeper changes required, namely making the workspace itself responsible for all changes. Looking into it.

@trueadm
Copy link
Collaborator Author

trueadm commented Oct 18, 2024

This works but the code makes me nervous. We shouldn't be selecting state inside a loop in update_files, it should be happening in response to a selection.

I tweaked it, we just need to setState. The reason we do it here is that the select_state happens before update_files occurs, and at that point it creates the wrong EditorState. So instead we wait for update_files to do it and also setState the latest state to ensure the view is up to date.

I think there are some deeper changes required, namely making the workspace itself responsible for all changes. Looking into it.

Sure thing, the invalidation sucks, but its necessary as the reason this fails is because workspace.compiled does not yet have the new compiled output for the filename. Invalidating ensures that it does have it, then when the AST Explorer tabs effect updates it works as intended.

@Rich-Harris
Copy link
Member

closing in favour of #460

@Conduitry Conduitry deleted the fix-editor-state branch October 23, 2024 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renaming a file in the playground causes content to clear Can't type into a newly created file in the playground

2 participants