ayecue / greybel-vs

VSCode extension for GreyScript.
https://marketplace.visualstudio.com/items?itemName=ayecue.greybel-vs
MIT License
15 stars 7 forks source link

Corruption of strings in Greybel #88

Closed Olipro closed 11 months ago

Olipro commented 11 months ago

Hi, me again!

I use a JSON parser lib originally written by the author of MiniScript. This script works fine in-game, however, when running in Greybel, there is some strange corruption going on:

  1. This one I have pinned down: the JSON library uses char(13) (\r) for newlines, attempting to print anything with this char in gives bad output. see the _eol variable in the JSON source.
  2. In Greybel, using the JSON lib to serialise a list results in an additional empty [] for no reason I can fathom. This does not happen inside the game, everything is serialised to valid and correct JSON. At a guess, I would suspect it is related to when the JSON lib escapes strings, but I really am just guessing.

This is a snippet of code to reproduce the issues:

l = [["string", 0], ["second", 1], ["third", 2]]
print JSON.toJSON(l)

Here is the JSON lib - note that I have already changed the _eol var in this source, so ensure you change it back if you wish to debug issue 1 (line 296) - https://gist.github.com/Olipro/2eebcca9fae6d70398ca9bdd7ce3eb64

ayecue commented 11 months ago

Thanks for reporting I found the culprit. Should be fixed as soon https://github.com/ayecue/greybel-vs/pull/90 gets merged. I'll give another update once that's done.

ayecue commented 11 months ago

https://github.com/ayecue/greybel-vs/pull/90 got merged. Can you please confirm it that fixed the issue for you?

Olipro commented 11 months ago

Confirmed working. Thanks!