[Fixed] Pasting perfect code causes syntax errors

Something has changed with the code editor in the last week. Anytime I paste in code now, there are always syntax errors. It’s adding extra indentations.

I will literally command+c to copy the code from the master branch, then delete the code from the master branch and then command+v to paste in the exact same master branch code back in and now all of a sudden there are new indentations that have been added and new syntax errors, which keeps my code from working.

I’ve tried different browsers and still the same issue.

Any ideas?

Here’s an example:

Original code:

try:
    # This will throw an error if the table doesn't exist
    app_tables.backgroundjobs
    print("backgroundjobs table found")
    
    # Check if the email_sent column exists
    try:
        # Try to read the email_sent column from one row
        jobs = app_tables.backgroundjobs.search()
        if jobs:
            test_job = jobs[0]
            # This will throw an error if the column doesn't exist
            test_email_sent = test_job.get('email_sent')
            print("email_sent column found")
    except:
        print("Note: email_sent column needs to be added to backgroundjobs table")
        print("- email_sent (text: yes/no)")

And what its like when I paste it back into the editor:

try:
  # This will throw an error if the table doesn't exist
  app_tables.backgroundjobs
  print("backgroundjobs table found")

  # Check if the email_sent column exists
  try:
    # Try to read the email_sent column from one row
    jobs = app_tables.backgroundjobs.search()
    if jobs:
      test_job = jobs[0]
      # This will throw an error if the column doesn't exist
      test_email_sent = test_job.get('email_sent')
      print("email_sent column found")
    except:
      print("Note: email_sent column needs to be added to backgroundjobs table")
      print("- email_sent (text: yes/no)")

I even paste the working, formatted code into an online python code editor and it pastes correctly formatted with no syntax issues. Its just Anvil’s editor that’s messing up the formatting.

Paste & match style doesn’t work either…

Thanks for reporting. Moved to bug reports.

Try ctrl + shift + v (cmd if on a Mac).

We have tried to adapt the indentation on paste to your preferred indentation (it looks like your copying code which is 4 space indented but have a 2 space preference). Which seems to be broken for the try, except block here.

We’ll investigate and see what’s going on.

2 Likes

This should now be fixed

2 Likes