microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
477 stars 207 forks source link

Code loss bug when switching typescript -> python in some circumstances #6028

Closed jwunderl closed 1 year ago

jwunderl commented 1 year ago

Describe the bug I believe I've seen this occur with other paths, so this is probably a general bug, but we need to clean up the 'source of truth' when switching between files

To Reproduce Steps to reproduce the behavior:

  1. Go to typescript project
  2. switch to python mode, make some changes
  3. go back to typescript, make some changes
  4. go to pxt.json via explorer, change description
  5. go to main.py via explorer
  6. code is same as end of step 2, not the latest version from step 3.

Expected behavior

We should properly track which variant of the file was last edited (main.ts, main.blocks, main.py) and not lose user code

Screenshots

thsparks commented 1 year ago

Is there any reason to keep the main.py file visible when in typescript mode? Or should we just hide *.py files altogether when in typescript (and vice versa)?

jwunderl commented 1 year ago

There's definitely some thinking we can do on the explorer in general (e.g. could collapse all main.whatever into one in the view with a dropdown or something), but I'd probably think of that as a separate enhancement -- even if this bug only repros under this circumstance right now there's most likely a hole somewhere we can clean up so we don't run into it again in the future.

thsparks commented 1 year ago

While trying to repro this, I'm finding that any javascript changes made after switching from javascript to python (then making a change), then back to javascript are completely ignored...still investigating, but thought it was worth a note.