Fix Non-Python Changes After Leaving Python Mode #9650
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fromappTarget.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