Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Non-Python Changes After Leaving Python Mode #9650

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

thsparks
Copy link
Contributor

@thsparks thsparks commented Aug 22, 2023

Fixes microsoft/pxt-arcade#6034. Essentially, if you switch to python and then change back to typescript or blocks, your typescript/blocks changes will be ignored.

This was happening because the preferred editor in our compile options remained set to python. The call to getPreferredEditor() was returning the correct value, but there's a scenario where, when iterating through variants, opts.target is overwritten with the old value from appTarget.compile (opts.target = etarget.target; in line 1235).

The simplest fix is to set the preferred editor after this happens, so we don't override it. A more involved solution would be to change how we're tracking the editor "mode" (js/py/blocks) and ensure a single source of truth, but I think that'd be a fairly extensive change with a high risk of severe regressions (i.e. code loss if we compile the wrong file, overwrite changes, etc...). Perhaps something to look at down the road, but probably not now...

Upload target: https://arcade.makecode.com/app/5b2685789e1b0aea9d81a9cb38c5162f0f367f74-7aafc43a06

There's a scenario when iterating through variants that causes us to overwrite the opts.target. We want to make sure we set the preferred editor after this happens so we don't override it.
@thsparks thsparks requested a review from a team August 22, 2023 22:45
@thsparks thsparks merged commit d1b7023 into master Aug 23, 2023
7 checks passed
@thsparks thsparks deleted the thsparks/fix_js_and_blocks_after_python branch August 23, 2023 17:13
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.

Making a Python Edit Prevents Future Edits in Blocks and Javascript
2 participants