Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

Fixes #68534

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner June 10, 2023 23:13
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 10, 2023
public void Visit(JsonCommaValueNode node)
{
AddClassification(node.CommaToken, ClassificationTypeNames.JsonPunctuation);
// already handled when we recurse in AddTokenClassifications
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I understand how the logic in here works. Why are commas special versus other types of tokens handled by the other visit methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commas are handled slightly specially in json (for error recovery purposes). They can both be a node (with a token in them), or just a token in separated list. We were only handling the first case.

Now we handle both cases by just checking the token case only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth documenting that :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought that comment was :'(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment explains a bit of the why, but not the "commas are special for error recovery" part. That's what I needed to know to understand the code 🙂.

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge June 12, 2023 03:10
@CyrusNajmabadi CyrusNajmabadi merged commit 4cbfec9 into dotnet:main Jun 12, 2023
@ghost ghost added this to the Next milestone Jun 12, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the jsonPunctuation branch June 12, 2023 04:34
@RikkiGibson RikkiGibson modified the milestones: Next, 17.7 P3 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LSP] [Bug]: Commas after non-array elements in JSON-like strings are colored incorrectly

3 participants