Skip to content

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Oct 10, 2025

fixes https://github.com/microsoft/pxt-minecraft/issues/2945

possibly also fixes the other code disappearing bugs, but i can't repro those so not sure.

this bug was caused by a race condition where the tutorial loading triggered a save operation while blockly was still being loaded. because the file hadn't been loaded yet, the editor would overwrite the file it was loading with an empty workspace thus erasing all the blocks.

i'm still not sure why this doesn't trigger in our other editors (like micro:bit), but i'm guessing it's just a trick of timing.

the fix here is to just prevent the editor from saving when it's loading a file. we already have an isIncomplete API which source editors implement to indicate when the editor is in a state where the source should not be saved (for example, while a block is being dragged by the user), so i've extended that logic to also check to see if a file is being loaded. i also moved the flag tracking that state earlier in the process so that we set it before the blockly load starts.

changing this stuff is always tricky, so we should make sure to really test this. i'd like to do a bigger refactor here but deliberately kept the change as minimal as possible.

@riknoll riknoll requested a review from a team October 10, 2025 22:06
@riknoll riknoll enabled auto-merge (squash) October 10, 2025 22:12
Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@riknoll riknoll merged commit 5d253da into master Oct 10, 2025
20 checks passed
@riknoll riknoll deleted the dev/riknoll/editorIncompleteLoad branch October 10, 2025 23:15
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.

2 participants