pybricks / support

Pybricks support and general discussion
MIT License
109 stars 7 forks source link

[Bug] Copy pasting generated Python code #1881

Open Devansh-awat opened 1 month ago

Devansh-awat commented 1 month ago

Describe the bug Python files turning into block files

To reproduce

  1. Copy a Python code from the read-only editor in blocks programming
  2. Create a new Python project and paste the code
  3. Go to another file
  4. Come back to the new file
  5. The file will now be a block file

Expected behaviour The Python file should have stayed a Python file

Video recording

https://github.com/user-attachments/assets/a0569722-3c2b-4747-b4e7-d2608e9a4c2f

laurensvalk commented 1 month ago

Thanks for reporting.

Block programs are Python files with the block representation stored as a comment on the first line.

When you copied the code, it also copied that first line. This isn't visible in your video, but you will see it if you scroll to the first line after pasting it in a new file. You can delete that first line to work around it.