afterschoolstudio / Depot

Structured data editor built inside VS Code
Apache License 2.0
186 stars 19 forks source link

Fix grid columns not getting clean default values #63

Closed andrewstart closed 5 months ago

andrewstart commented 5 months ago

Makes a copy of the default value for any array type - this is intended for fixing just grid columns, but if there are other array values I am pretty sure this is the correct way to do it anyway. I noticed that when adding lines with a grid column, the new lines were sharing their array reference with the default value and each other until the file was reopened.

kkukshtel commented 5 months ago

@andrewstart Thanks so much for submitting a PR! Can you give an example of the behavior before and after just so I get a sense of what was happening now vs. then? The Grid type is one I haven't used much so I'm sure there's probably weird things in there with it.

andrewstart commented 5 months ago

With a your grid column (of any size) defined in your document, create multiple lines and open up the grid in all of them.

Before:

  1. Editing one row would cause immediate changes in the other rows.
  2. After making changes, saving, closing and reopening your document would separate the existing rows from further simultaneous editing, but upon making a new row, you would see that you had edited the default value before.

After: Each row gets its own copy of the default value instead of a reference to it, so changing one row never affects other rows or the default value for future rows.

kkukshtel commented 5 months ago

Ah gotcha, sounds great! I'll merge this... and also need to figure out again how to republish the extension with the fix. Also tagging you in another issue that might be related to a similar thing.