Nixinova / NovaLightshow

A replacement for GitHub LightShow.
https://novalightshow.netlify.app
ISC License
3 stars 3 forks source link

TypeError: Expected `string` for `scope`, got `undefined` #5

Open TheWitheredStriker opened 10 months ago

TheWitheredStriker commented 10 months ago

This error keeps happening with most (though not all) of the grammars I'm testing. This includes grammars that don't even have a scope property, like this one.

I'm not sure why this happens, any ideas?

Nixinova commented 10 months ago

Will look into this, thanks for the report.

Nixinova commented 10 months ago

Looks like its an issue with parsing CSON grammar. If i convert your example to JSON then it works fine https://www.convertsimple.com/convert-cson-to-json/. Will see how I can fix this, but that is a workaround in the meantime.

TheWitheredStriker commented 10 months ago

It doesn't seem to exclusively be a CSON problem. It occurs with YAML too, like this one.

EDIT: I also tried converting the YAML to JSON and I still get the error.

Nixinova commented 9 months ago

Looking into it, the error seems to be here: https://github.com/Nixinova/NovaLightshow/blob/1a0a549c1975f5db81ae54b4bb90584c14a5a5fd/index.mjs#L36 When there is an unexpected scopeName property the code doesn't work.

For instance your latest example file:

https://github.com/mitranim/sublime-forth/blob/2293f5c0fd65a141e246880b7c8146affd94c29f/Forth.sublime-syntax#L2-L5

scope: source.forth

It says scope not scopeName. So I'll have to change the code to take that into account. Hopefully that fixes this

Nixinova commented 9 months ago

Try it now, hopefully fixed.

TheWitheredStriker commented 9 months ago

I don't get the error anymore, but when trying the Forth grammar, the code is displayed but not highlighted: image

Trying the CSON Factor grammar up top also still throws the same error. Sorry!

Nixinova commented 9 months ago

Hmm that's interesting. Welp, will have to do fix attempt two.

Nixinova commented 1 month ago

Ah - this is a bug in the CSON parser, https://github.com/fabiospampinato/cson2json/issues/1.

Seems like it can't handle mixed indents:

repository:
  escaped_characters:
    patterns: true
scope: "source.factor"
scopeName: "source.factor"

image

Will have to switch CSON parser.

Nixinova commented 1 month ago

It doesn't seem to exclusively be a CSON problem. It occurs with YAML too, like this one.

EDIT: I also tried converting the YAML to JSON and I still get the error.

The previous fix resolves this problem, but the original issue is with the CSON.